Вроде ошибка в интернете есть, но попробовал решить — не помогло. Код:
>>> pip install
Ошибка:
File "<stdin>", line 1
pip install
^
SyntaxError: invalid syntax
Что делать? С путём всё нормально вроде.
Пушистик
4673 серебряных знака15 бронзовых знаков
задан 2 мар 2018 в 16:56
Антон ВасиленкоАнтон Василенко
511 золотой знак2 серебряных знака7 бронзовых знаков
11
В Вашей строке вижу:
>>> pip install ...
Так понимаю, Вы запускаете в интерактивном режиме python (сам так первый раз запустил). pip
запускается из командной строки Вашей ОС.
Запускаем cmd
, пишем pip install ...
и Enter
0xdb
51.5k198 золотых знаков59 серебряных знаков237 бронзовых знаков
ответ дан 2 мар 2018 в 17:15
2
А вас нечего не смущает? Что допустим ошибка не характерна для cmd.exe.
Решение:
Заходишь в cmd.exe и пишешь
>>>cd путь_к_python\Scripts
>>>pip install модуль который вы хотите установить
А вы зачем то вызываете команду для cmd с консоли python…
ответ дан 4 мар 2018 в 17:09
GlebGleb
8194 золотых знака15 серебряных знаков31 бронзовый знак
0
не уверен, но
python -m pip install SomePackage
https://docs.python.org/3/installing/index.html#basic-usage
если не ошибаюсь, с третьей версии питона используется конструкция вида
python -m `имя модуля`
например
python -m http.server 8000
посмотреть версию
python -V
в третьем питоне создать виртуальное окружение и установить в него пакет
по шагам, проверено в линуксе, в винде, предположительно, отличаются только первые два шага
создать директорию
mkdir test
перейти в неё
cd test
создать окружение
python3 -m venv .env
зайти в него
source .env/bin/activate
установить пакет
python -m pip install django
окружение будет находиться в директории .env
https://stackoverflow.com/a/47196099/4794368 — а тут можно почитать как это всё объединить с VSCode
ответ дан 2 мар 2018 в 17:35
qwabraqwabra
4,9521 золотой знак8 серебряных знаков27 бронзовых знаков
если 3я версия python, то в cmd попробуйте pip3 install "название библиотеки"
ответ дан 3 мар 2018 в 6:13
lynxlynx
4304 серебряных знака19 бронзовых знаков
Для Windows
- WIN + R
- Ввести
cmd
и нажать ENTER - Ввести команду и нажать ENTER:
>>> pip install название_пакета
Для Linux или macOS
- Открыть терминал.
- Ввести команду и нажать ENTER:
>>> pip install название_пакета
>>>
это приглашение, оно может быть разное, например:C:\>
,$
или#
.
ответ дан 5 авг 2022 в 17:16
ПушистикПушистик
4673 серебряных знака15 бронзовых знаков
Короче нашел вот такой код:
python -m pip install -U pip
видимо pip у меня не был установлен(или обновлен) и это помогло.
а уже потом pip install django сработало
всё это нужно делать в командной строке
ответ дан 3 мар 2018 в 16:26
Антон ВасиленкоАнтон Василенко
511 золотой знак2 серебряных знака7 бронзовых знаков
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.
Table of Contents
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:
- Press Win + R, type
appwiz.cpl
, and press Enter. - Select Python from the list and press Change.
- Click on Modify. Ensure pip is selected and press Next > Install.
- 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:
- Press Win + R, type
cmd
, and press CTRL + Shift + Enter. - Type
echo %PATH%
and press Enter.
Depending on your Python version and install location, you may see a path like C:\Python36\Scripts
. 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:
- Execute the following command:
setx PATH "%PATH%;<PIP Path>"
As stated, the PIP path will differ according to your Python version. We’ve usedC:\Python36\Scripts
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. - 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:
- Press Win + R, type
sysdm.cpl
, and press Enter. - Switch to the Advanced tab and click on Environment Variables.
- In the System variables section, select Path and press Edit.
- 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:\Users\Username\AppData\Local\Programs\Python\Python310\Scripts
. - 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
If you have multiple python versions, specify the version number as shown below:
py -3 -m pip install packagename
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:
- Download get-pip.py and store it in Python’s installation directory.
- Enter
cd <above directory>
to switch to the installation directory in CMD. - Type
py get-pip.py
and press Enter. - 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
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:
- Press Win + R, type appwiz.cpl, and press Enter.
- Select Python from the list, click on Uninstall and follow the on-screen instructions.
- Restart your PC and reinstall Python.
- Enable the Add Python to Path option and select Customize installation. Also, make sure that PIP is included during the installation.
- After the installation completes, restart your PC once more, then check if you can install any Python packages.
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:\Users\jnunn\Desktop>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:\Python26\ArcGIS10.1\Scripts
Installing pip.exe script to C:\Python26\ArcGIS10.1\Scripts
Installing pip.exe.manifest script to C:\Python26\ArcGIS10.1\Scripts
Installing pip-2.7-script.py script to C:\Python26\ArcGIS10.1\Scripts
Installing pip-2.7.exe script to C:\Python26\ArcGIS10.1\Scripts
Installing pip-2.7.exe.manifest script to C:\Python26\ArcGIS10.1\Scripts
Successfully installed pip
Cleaning up...
C:\Users\jnunn\Desktop>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.0\VC\BIN\cl.exe /c /nologo
/Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -I
C:\Python26\ArcGIS10.1\include -IC:\Python26\ArcGIS10.1\PC -IC:\Python26\ArcGIS1
0.1\lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\te
mp.win32-2.7\Release\extensions/gdal_wrap.obj
gdal_wrap.cpp
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(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.0\VC\BIN\c
l.exe"' failed with exit status 2
Complete output from command C:\Python26\ArcGIS10.1\python.exe -c "import se
tuptools;__file__='c:\\users\\jnunn\\appdata\\local\\temp\\pip-build\\gdal\\setu
p.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'
))" install --record c:\users\jnunn\appdata\local\temp\pip-f7tgze-record\install
-record.txt --single-version-externally-managed:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying gdal.py -> build\lib.win32-2.7
copying ogr.py -> build\lib.win32-2.7
copying osr.py -> build\lib.win32-2.7
copying gdalconst.py -> build\lib.win32-2.7
copying gdalnumeric.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\osgeo
copying osgeo\gdal.py -> build\lib.win32-2.7\osgeo
copying osgeo\gdalconst.py -> build\lib.win32-2.7\osgeo
copying osgeo\gdalnumeric.py -> build\lib.win32-2.7\osgeo
copying osgeo\gdal_array.py -> build\lib.win32-2.7\osgeo
copying osgeo\ogr.py -> build\lib.win32-2.7\osgeo
copying osgeo\osr.py -> build\lib.win32-2.7\osgeo
copying osgeo\__init__.py -> build\lib.win32-2.7\osgeo
running build_ext
building 'osgeo._gdal' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\extensions
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -IC:\P
ython26\ArcGIS10.1\include -IC:\Python26\ArcGIS10.1\PC -IC:\Python26\ArcGIS10.1\
lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\temp.w
in32-2.7\Release\extensions/gdal_wrap.obj
gdal_wrap.cpp
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(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.0\VC\BIN\cl.ex
e"' failed with exit status 2
----------------------------------------
Command C:\Python26\ArcGIS10.1\python.exe -c "import setuptools;__file__='c:\\us
ers\\jnunn\\appdata\\local\\temp\\pip-build\\gdal\\setup.py';exec(compile(open(_
_file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\u
sers\jnunn\appdata\local\temp\pip-f7tgze-record\install-record.txt --single-vers
ion-externally-managed failed with error code 1 in c:\users\jnunn\appdata\local\
temp\pip-build\gdal
Storing complete log in C:\Users\jnunn\pip\pip.log
C:\Users\jnunn\Desktop>
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.0\VC\INCLUDE\xlocale(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.0\VC\BIN\cl.ex
e"' failed with exit status 2
Plus the following additional pip.log:
Exception information:
Traceback (most recent call last):
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\basecommand.py", line 107, in main
status = self.run(options, args)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\commands\install.py", line 261, in run
requirement_set.install(install_options, global_options)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\req.py", line 1166, in install
requirement.install(install_options, global_options)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\req.py", line 589, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\util.py", line 612, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command C:\Python26\ArcGIS10.1\python.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:\users\jnunn\appdata\local\temp\pip-f7tgze-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\jnunn\appdata \local\temp\pip-build\gdal
При попытке установки практически любой библиотеки через pip возникает ошибка:
На примере библиотеки requests:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499A760>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499A910>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499A9E8>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499AAC0>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499AB98>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.2
8.1-py3-none-any.whl (Caused by NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499AC70>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
Однако, например с библиотекой aiogram всё работает исправно Так же ошибка начала появляться только сегодня, вчера я мог устанавливать все библиотеки без труда через терминал
Как исправить эту ошибку для установки нужных мне библиотек?
Важно: я использую интерпретатор PyCharm, устанавливаю библиотеки через него, однако при установке через cmd происходит аналогичная ситуация и та же ошибка
-
Home
-
Partition Manager
- 4 Ways to Fix the Pip Install Not Working Issue
By Linda | Follow |
Last Updated
Is pip install not working? The pip install command is used to install packages. If it is not working, you may receive various errors when you run it. This post from MiniTool Partition Wizard offers you 4 ways to solve this issue.
Pip Install Not Working
Pip is the default package-management system written in Python and is used to install and manage software packages. Most distributions of Python come with pip preinstalled.
After installing Python and pip, you can use the pip install command to install packages. The command formula is as follows: pip install some-package-name.
However, some people report that they have encountered the pip install not working issue. When they run the pip install command, they may receive the “pip command not found” or “pip is not recognized” error.
Why does the pip install not working issue occurs? Possible reasons are as follows:
- Pip is not installed.
- Pip is not added to the PATH environment.
- Pip is installed, but it is not compatible with the current environment.
How to Fix the Pip Install Not Working Issue
If you encounter the “pip command not found” or “pip is not recognized” error, you can try the following methods to solve them. But which method should you use? You need to decide after checking Python and pip versions. Here is the guide:
- Open Command Prompt.
- Execute the command “python -v”. It will tell you the python version.
- Execute the command “pip –version”. It will tell you the pip version. If you encounter errors in this step, it means that pip is not installed or not added to the PATH environment.
- Then, you need to see if their versions are the same. If not, you need to update pip or reinstall it.
Way 1. Install Pip
If pip is not installed, you can install it by executing the following commands:
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- python get-pip.py (If your Python is 3.x version, please execute python3 get-pip.py)
The first command will download the installation script and the second command will run the script. Now, you can find the pip.exe under the Python scripts directory.
Way 2. Add Pip to PATH
If you didn’t change the installation location, the default pip path should be C:UsersUsernameAppDataLocalProgramsPythonPython310Scripts. Now, you should add this path to the environment variables. Here is the guide:
- Press “Windows key + R” to open the Run dialog box.
- In the Run box, type “sysdm.cpl” and press Enter to open the System Properties window.
- Go to the Advanced tab and click Environment Variables.
- Double-click the PATH variable under System Variables.
- Click New, and add the pip path. Then, select OK.
Way 3. Update Pip
If the pip version is lower than the Python version, you may need to upgrade pip using the command “pip install -U pip”. If this command doesn’t work, you can try this command “easy_install –upgrade pip”.
Way 4. Reinstall Python and Pip
If all the above ways don’t work, I recommend you reinstall Python and pip. You need to uninstall Python first and then you can install the latest Python. This time, please remember to install pip and add it to the path.
Bottom Line
Are you interested in MiniTool Partition Wizard? This software can help you clone the system, manage disks better, and recover data. If you have this need, you can download it from the official website.
About The Author
Position: Columnist
Linda has been working as an editor at MiniTool for 5 years. She is always curious about computer knowledge and learns it crazily. Her articles are simple and easy to understand. Even people who do not understand computer can gain something. By the way, her special focuses are disk management, data recovery and PDF editing.