Python ошибка при установке пакетов

This is the full text of the blog post linked below:

If you’ve tried installing a package with pip recently, you may have encountered this error:

Could not fetch URL https://pypi.python.org/simple/Django/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/Django/ when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Could not fetch URL https://pypi.python.org/simple/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/ when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/Django/1.5.1: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/Django/1.5.1 when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Could not fetch URL https://pypi.python.org/simple/Django/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
  Will skip URL https://pypi.python.org/simple/Django/ when looking for download links for Django==1.5.1 (from -r requirements.txt (line 1))
  Could not find any downloads that satisfy the requirement Django==1.5.1 (from -r requirements.txt (line 1))
No distributions at all found for Django==1.5.1 (from -r requirements.txt (line 1))
Storing complete log in /Users/paul/.pip/pip.log

This seems to be an issue with an old version of OpenSSL being incompatible with pip 1.3.1. If you’re using a non-stock Python distribution (notably EPD 7.3), you’re very likely to have a setup that isn’t going to work with pip 1.3.1 without a shitload of work.

The easy workaround for now, is to install pip 1.2.1, which does not require SSL:

curl -O https://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz
tar xvfz pip-1.2.1.tar.gz
cd pip-1.2.1
python setup.py install

If you are using EPD, and you’re not using it for a class where things might break, you may want to consider installing the new incarnation: Enthought Canopy. I know they were aware of the issues caused by the previous version of OpenSSL, and would imagine they are using a new version now that should play nicely with pip 1.3.1.

I’m having trouble installing python modules using pip. Below is the output from the command window:

Note that I installed pip immediately before trying to install GDAL module.

I am on a w7 64bit machine running python 2.7

    Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:UsersjnunnDesktop>python get-pip.py
Downloading/unpacking pip
Downloading pip-1.2.1.tar.gz (102Kb): 102Kb downloaded
Running setup.py egg_info for package pip

warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory
'docs_build'
no previously-included directories found matching 'docs_build_sources'
Installing collected packages: pip
Running setup.py install for pip

warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory
'docs_build'
no previously-included directories found matching 'docs_build_sources'
Installing pip-script.py script to C:Python26ArcGIS10.1Scripts
Installing pip.exe script to C:Python26ArcGIS10.1Scripts
Installing pip.exe.manifest script to C:Python26ArcGIS10.1Scripts
Installing pip-2.7-script.py script to C:Python26ArcGIS10.1Scripts
Installing pip-2.7.exe script to C:Python26ArcGIS10.1Scripts
Installing pip-2.7.exe.manifest script to C:Python26ArcGIS10.1Scripts
Successfully installed pip
Cleaning up...

C:UsersjnunnDesktop>pip install gdal
Downloading/unpacking gdal
Downloading GDAL-1.9.1.tar.gz (420kB): 420kB downloaded
Running setup.py egg_info for package gdal

Installing collected packages: gdal
Running setup.py install for gdal
building 'osgeo._gdal' extension
c:Program Files (x86)Microsoft Visual Studio 9.0VCBINcl.exe /c /nologo
/Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -I
C:Python26ArcGIS10.1include -IC:Python26ArcGIS10.1PC -IC:Python26ArcGIS1
0.1libsite-packagesnumpycoreinclude /Tpextensions/gdal_wrap.cpp /Fobuildte
mp.win32-2.7Releaseextensions/gdal_wrap.obj
gdal_wrap.cpp
c:Program Files (x86)Microsoft Visual Studio 9.0VCINCLUDExlocale(342) :
warning C4530: C++ exception handler used, but unwind semantics are not enabled
. Specify /EHsc
extensions/gdal_wrap.cpp(2853) : fatal error C1083: Cannot open include file
: 'cpl_port.h': No such file or directory
error: command '"c:Program Files (x86)Microsoft Visual Studio 9.0VCBINc
l.exe"' failed with exit status 2
Complete output from command C:Python26ArcGIS10.1python.exe -c "import se
tuptools;__file__='c:\users\jnunn\appdata\local\temp\pip-build\gdal\setu
p.py';exec(compile(open(__file__).read().replace('rn', 'n'), __file__, 'exec'
))" install --record c:usersjnunnappdatalocaltemppip-f7tgze-recordinstall
-record.txt --single-version-externally-managed:
running install

running build

running build_py

creating build

creating buildlib.win32-2.7

copying gdal.py -> buildlib.win32-2.7

copying ogr.py -> buildlib.win32-2.7

copying osr.py -> buildlib.win32-2.7

copying gdalconst.py -> buildlib.win32-2.7

copying gdalnumeric.py -> buildlib.win32-2.7

creating buildlib.win32-2.7osgeo

copying osgeogdal.py -> buildlib.win32-2.7osgeo

copying osgeogdalconst.py -> buildlib.win32-2.7osgeo

copying osgeogdalnumeric.py -> buildlib.win32-2.7osgeo

copying osgeogdal_array.py -> buildlib.win32-2.7osgeo

copying osgeoogr.py -> buildlib.win32-2.7osgeo

copying osgeoosr.py -> buildlib.win32-2.7osgeo

copying osgeo__init__.py -> buildlib.win32-2.7osgeo

running build_ext

building 'osgeo._gdal' extension

creating buildtemp.win32-2.7

creating buildtemp.win32-2.7Release

creating buildtemp.win32-2.7Releaseextensions

c:Program Files (x86)Microsoft Visual Studio 9.0VCBINcl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -IC:P
ython26ArcGIS10.1include -IC:Python26ArcGIS10.1PC -IC:Python26ArcGIS10.1
libsite-packagesnumpycoreinclude /Tpextensions/gdal_wrap.cpp /Fobuildtemp.w
in32-2.7Releaseextensions/gdal_wrap.obj

gdal_wrap.cpp

c:Program Files (x86)Microsoft Visual Studio 9.0VCINCLUDExlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc

extensions/gdal_wrap.cpp(2853) : fatal error C1083: Cannot open include file: 'c
pl_port.h': No such file or directory

error: command '"c:Program Files (x86)Microsoft Visual Studio 9.0VCBINcl.ex
e"' failed with exit status 2

----------------------------------------
Command C:Python26ArcGIS10.1python.exe -c "import setuptools;__file__='c:\us
ers\jnunn\appdata\local\temp\pip-build\gdal\setup.py';exec(compile(open(_
_file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record c:u
sersjnunnappdatalocaltemppip-f7tgze-recordinstall-record.txt --single-vers
ion-externally-managed failed with error code 1 in c:usersjnunnappdatalocal
temppip-buildgdal
Storing complete log in C:Usersjnunnpippip.log

C:UsersjnunnDesktop>

I have tried to use easy_install before too, and it came back with a common error to this:

c:Program Files (x86)Microsoft Visual Studio 9.0VCINCLUDExlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc

extensions/gdal_wrap.cpp(2853) : fatal error C1083: Cannot open include file: 'c
pl_port.h': No such file or directory

error: command '"c:Program Files (x86)Microsoft Visual Studio 9.0VCBINcl.ex
e"' failed with exit status 2

Plus the following additional pip.log:

    Exception information:
Traceback (most recent call last):
File "C:Python26ArcGIS10.1libsite-packagespipbasecommand.py", line 107, in main
status = self.run(options, args)
File "C:Python26ArcGIS10.1libsite-packagespipcommandsinstall.py", line 261, in run
requirement_set.install(install_options, global_options)
File "C:Python26ArcGIS10.1libsite-packagespipreq.py", line 1166, in install
requirement.install(install_options, global_options)
File "C:Python26ArcGIS10.1libsite-packagespipreq.py", line 589, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "C:Python26ArcGIS10.1libsite-packagespiputil.py", line 612, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command C:Python26ArcGIS10.1python.exe -c "import setuptools;__file__='c:\users\jnunn\appdata\local\temp\pip-build\gdal\setup.py';exec(compile(open(__file__).read().replace('r    n', 'n'), __file__, 'exec'))" install --record c:usersjnunnappdatalocaltemppip-f7tgze-recordinstall-record.txt --single-version-externally-managed failed with error code 1 in c:usersjnunnappdata    localtemppip-buildgdal

Package Installer for Python (PIP) is the preferred package-management system for Python. It’s used to install third-party packages from an online repository called the Python Package Index.

When attempting to install Python packages, you may encounter errors stating PIP is not recognized, command not found, or can’t open the file. In this article, we’ve detailed why such errors occur, as well as how you can fix them.

Why is the PIP Install Not Working?

The most common reasons for issues with PIP installations is either that an incorrect PIP path is added to the PATH system variable, or the PIP path isn’t added at all. This often happens because users forget or don’t know to include PIP during the Python installation. In case of Linux, PIP isn’t included during the Python installation to start with, so you have to install it separately later.

In most cases, you won’t encounter this error if you use a Python IDE instead of CMD. However, if you don’t want to use an IDE, or you face this error despite using an IDE, you can try the fixes from the section below to resolve the issue.

Include PIP During Installation

First, you should make sure that PIP was actually included during the Python installation. Here are the steps to do so:

  1. Press Win + R, type appwiz.cpl, and press Enter.
  2. Select Python from the list and press Change.
  3. Click on Modify. Ensure pip is selected and press Next > Install.
    install-pip-python-optional-features
  4. After the installation completes, check if you can install the Python packages now.

Add PIP to PATH Variable

As stated, the PIP Install path needs to be added to the PATH system variable for it to work. Otherwise, CMD won’t recognize the command and you’ll encounter the not recognized error. First, you should check if this is the issue with the following steps:

  1. Press Win + R, type cmd, and press CTRL + Shift + Enter.
  2. Type echo %PATH% and press Enter.
    echo-path

Depending on your Python version and install location, you may see a path like C:Python36Scripts. This means the PIP path is already added to the PATH variable. If you don’t see it, you can add it via the command line with the following steps:

  1. Execute the following command:
    setx PATH "%PATH%;<PIP Path>"
    setx-path-python
    As stated, the PIP path will differ according to your Python version. We’ve used C:Python36Scripts as an example but in your case, the PIP path maybe different. If you aren’t sure what the PIP path is, check the GUI method below.
  2. Start a new instance of command prompt and check if you can install any packages.

The command-line interface method returns a lot of paths at once, which can get confusing. Instead, you can also check the paths via the GUI. Here are the steps to do so:

  1. Press Win + R, type sysdm.cpl, and press Enter.
  2. Switch to the Advanced tab and click on Environment Variables.
    environment-variables
  3. In the System variables section, select Path and press Edit.
  4. Click on New and add the pip installation path. This differs depending on your Python version but for the current latest version (3.10), the path is:
    C:UsersUsernameAppDataLocalProgramsPythonPython310Scripts.
    add-new-path-variable
  5. Check if you can install a pip package now.

Use Correct PIP and Python Version

The pip install packagename command is generally used to install Python packages. If this command doesn’t work, you can try the commands shown below instead. Don’t forget to replace packagename with the actual package you’re trying to install.

python -m pip install packagename

py -m pip install packagename

pip-install-packagename

If you have multiple python versions, specify the version number as shown below:

py -3 -m pip install packagename

install-pip-package-version-number

Manually Install PIP

Due to failed upgrades and similar issues, your PIP file can get corrupted which can also lead to various problems such as PIP Install Not Working. One easy way to fix this is by removing Python and reinstalling it. You can find the steps to do so in the next section.

Alternatively, you can also manually install PIP with the following steps:

  1. Download get-pip.py and store it in Python’s installation directory.
  2. Enter cd <above directory> to switch to the installation directory in CMD.
    python-install-directory
  3. Type py get-pip.py and press Enter.
    py-get-pip
  4. Once pip is installed, check if you can install any packages.

In case of Linux, pip doesn’t come bundled with Python. You have to manually install it first. You can do so by executing the following command in the terminal:

sudo apt-get -y install python3-pip

install-python-pip-ubuntu

Reinstall Python

The final option is to remove Python entirely and then reinstall it. Any problematic files will be replaced during the process, which should ultimately resolve the issue. Here are the steps to do so:

  1. Press Win + R, type appwiz.cpl, and press Enter.
  2. Select Python from the list, click on Uninstall and follow the on-screen instructions.
  3. Restart your PC and reinstall Python.
  4. Enable the Add Python to Path option and select Customize installation. Also, make sure that PIP is included during the installation.
    install-python-add-python-to-path
  5. After the installation completes, restart your PC once more, then check if you can install any Python packages.

You might encounter a problem when installing a Python package in the project settings or in the Python Package tool window. Eventually, most of the issues are out of IDE control as PyCharm uses the pip package manager to perform the actual installation.

This article provides troubleshooting tips and covers some typical cases.

Install a package using the Terminal

The most viable troubleshooting action is to try installing the problematic package on the selected Python interpreter using the terminal. If you get an identical error message, then the problem is not in the IDE and you should review the rationales and typical cases, or search for a solution on the Internet.

Install a package on a virtual environment

  1. Press Ctrl+Alt+S to open the IDE settings and select .

  2. Expand the list of the available interpreters and click Show All.

    Show all available interpreters

  3. Locate the target interpreter and press edit interpreter.

    Discover the interpreter path for the selected venv

    Copy or memorize the path of the virtual environment and close the dialogs.

  4. Open the terminal and run the following commands:

    source <venv path>/bin/activate
    pip install <package name>

    Installing a Python package on a virtual environment

  5. Inspect and parse the results.

Install a package on a Conda environment

  1. Open the terminal and run the following commands:

    Conda < 4.6

    Conda >= 4.6

    activate <conda env name>
    conda install <package name>

    conda activate <conda env name>
    conda install <package name>

    Conda < 4.6

    Conda >= 4.6

    source activate <conda env name>
    conda install <package name>

    conda activate <conda env name>
    conda install <package name>

    See Conda documentation for more information on how to activate an environment.

    Installing a Python package on a virtual environment

    One of the possible failure cases occurs when the target package is not available in the repositories supported by the Conda package manager.

    Fail to install a package on a Conda environment

  2. Inspect and parse the results.

Install a package on a system interpreter

  1. To check the path of the currently selected system interpreter that you were trying to install a package on, press Ctrl+Alt+S and go to .

  2. Expand the list of the project interpreters and scroll it down, then select the item.

    Selected Python interpreter

  3. Locate the interpreter and press edit interpreter.

    Discover the interpreter path for the selected venv

    Copy or memorize the path of the environment and close the dialogs.

  4. Open the terminal and run the following commands:

    cd <interpreter path>
    -m pip install <package name>

    Installing a Python package on a system environment

    You might need the admin privileges to install packages on a system interpreter.

  5. Inspect and parse the results.

Parse the results

Result

Action

The package cannot be installed because the Python version doesn’t satisfy the package requirement.

Try to create another Python interpreter that is based on the Python version that meets the requirement.

The package cannot be installed because you don’t have permissions to install it.

Try to install the package using super-user privileges, for example, sudo pip install <package name>.

The package cannot be installed because the package is not available in the repository that is supported by the selected package manager. Example: you’re trying to install a package that is not available in the Conda package manager repositories.

Try to configure another type of Python interpreter for your project and install the package on it. See how to add and modify a Python interpreter in Configure a Python interpreter.

The package cannot be installed and it matches one of the typical package installation failure cases.

Check the cases and apply related workarounds.

The package is successfully installed.

File an issue in the PyCharm issue tracker and provide explicit details about the case including all console output, error messages, and screenshots indicating that you tried to install the package on the same interpreter in the terminal and in the project settings or in the Python Packages tool window.

Review typical cases

Last modified: 16 December 2022

Студворк — интернет-сервис помощи студентам

Ребят, всем привет. Такая беда. При установке пакетов вылезают такие ошибки.

Кликните здесь для просмотра всего текста

C:UsersНР>pip install python-docx
Collecting python-docx
Using cached python-docx-0.8.6.tar.gz
Requirement already satisfied: lxml>=2.3.2 in c:usersнрappdatalocalprograms
pythonpython36-32libsite-packages (from python-docx)
Installing collected packages: python-docx
Running setup.py install for python-docx … error
Exception:
Traceback (most recent call last):
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
pipcompat__init__.py», line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xed in position 48: invalid
continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
pipbasecommand.py», line 215, in main
status = self.run(options, args)
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
pipcommandsinstall.py», line 342, in run
prefix=options.prefix_path,
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
pipreqreq_set.py», line 784, in install
**kwargs
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
pipreqreq_install.py», line 878, in install
spinner=spinner,
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
piputils__init__.py», line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File «c:usersнрappdatalocalprogramspythonpython36-32libsite-packages
pipcompat__init__.py», line 75, in console_to_str
return s.decode(‘utf_8’)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xed in position 48: invalid
continuation byte

в чём беда? стоит windows 8. Заранее спасибо.

  • Python ошибка при установке 0x80072f7d
  • Python как узнать тип ошибки
  • Python ошибка при запуске приложения 0xc000007b
  • Python как вызвать ошибку
  • Python ошибка ввода данных