OS: Mac OS X 10.7.5
Python Ver: 2.7.5
I have installed setuptools 1.0 with ez_setup.py from https://pypi.python.org/pypi/setuptools
Then I downloaded pip.1.4.1 pkg from https://pypi.python.org/pypi/pip/1.4.1.
I ran (sudo) python setup.py install
in iTerm, output:
running install
running bdist_egg running egg_info writing requirements to
pip.egg-info/requires.txt writing pip.egg-info/PKG-INFO writing
top-level names to pip.egg-info/top_level.txt writing dependency_links
to pip.egg-info/dependency_links.txt writing entry points to
pip.egg-info/entry_points.txt warning: manifest_maker: standard file
'setup.py' not found
reading manifest file 'pip.egg-info/SOURCES.txt' writing manifest file
'pip.egg-info/SOURCES.txt' installing library code to
build/bdist.macosx-10.6-intel/egg running install_lib warning:
install_lib: 'build/lib' does not exist -- no Python modules to
install
creating build/bdist.macosx-10.6-intel/egg creating
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/PKG-INFO -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying pip.egg-info/SOURCES.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/dependency_links.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/entry_points.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/not-zip-safe ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/requires.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/top_level.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO creating
'dist/pip-1.4.1-py2.7.egg' and adding
'build/bdist.macosx-10.6-intel/egg' to it removing
'build/bdist.macosx-10.6-intel/egg' (and everything under it)
Processing pip-1.4.1-py2.7.egg removing
'/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg'
(and everything under it) creating
/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg
Extracting pip-1.4.1-py2.7.egg to
/Users/dl/Library/Python/2.7/lib/python/site-packages pip 1.4.1 is
already the active version in easy-install.pth Installing pip script
to /Users/dl/Library/Python/2.7/bin Installing pip-2.7 script to
/Users/dl/Library/Python/2.7/bin
Installed
/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg
Processing dependencies for pip==1.4.1 Finished processing
dependencies for pip==1.4.1
Then I ran pip install
and got the following error message:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 357, in load_entry_point
File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 2394, in load_entry_point
File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 2108, in load
ImportError: No module named pip
Is there anyone who met the same problem before and can give me some tips to solve it?
tom
21.6k6 gold badges42 silver badges36 bronze badges
asked Aug 21, 2013 at 16:34
6
My solution for Ubuntu machine:
For Python 3
sudo apt install python3-pip
For Python 2
sudo apt install python-pip
OneCricketeer
176k18 gold badges130 silver badges239 bronze badges
answered Jun 14, 2016 at 8:15
5
With macOS 10.15 and Homebrew 2.1.6 I was getting this error with Python 3.7. I just needed to run:
python3 -m ensurepip
Now python3 -m pip
works for me.
answered Jul 5, 2019 at 3:14
kainjowkainjow
3,7651 gold badge19 silver badges17 bronze badges
6
On Mac using brew is a better option as apt-get is not available.
Command:
brew install python
In case you have both python2 & python3 installed on machine
python2.7 -m ensurepip --default-pip
simply should solve the issue.
If instead you are missing pip from python 3 then simply change python2.7
to python3
in the command above.
answered Oct 8, 2017 at 12:17
iosCuratoriosCurator
4,3462 gold badges21 silver badges25 bronze badges
5
For Windows:
python -m ensurepip
After activating your environment. Example: venv
(venv) PS D:your path> d:your pathvenvscriptspython.exe -m pip install --upgrade pip
Sample of a result:
Collecting pip
Using cached pip-21.3-py3-none-any.whl (1.7 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
Uninstalling pip-20.1.1:
Successfully uninstalled pip-20.1.1
Successfully installed pip-21.3
answered Oct 20, 2021 at 23:42
1
After installing ez_setup, you should have easy_install
available. To install pip
just do:
easy_install pip
answered Oct 27, 2014 at 14:21
ManuManu
3,1721 gold badge15 silver badges14 bronze badges
4
Run
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then run the following command in the folder where you downloaded: get-pip.py
python get-pip.py
answered Nov 29, 2020 at 16:52
AllisLoveAllisLove
4404 silver badges11 bronze badges
2
On some kind of Linux, like distributions based on Debian, you might want to consider updating your ‘apt-get‘ first, in case you are installing python-pip through it.
sudo apt-get update
This might help apt-get to update its indexes and locate the python-pip package.
After this, you might install pip like this:
sudo apt-get install python-pip (Python 2)
sudo apt-get install python3-pip (Python 3)
answered Apr 21, 2020 at 18:23
ANUP SAJJANANUP SAJJAN
1,43812 silver badges17 bronze badges
1
I encountered the same error with Python 3.8.6 on macOS v11 (Big Sur).
Whether I used pip
or pip3
, I’d get this error:
File "/Users/marcelloromani/dev/<repository>/venv/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
It turns out my virtualenv was out of date.
This fixed the issue for me:
-
Remove the old virtualenv
deactivate rm -rf venv
-
Initialise a new virtualenv
virtualenv venv . venv/bin/activate
-
Install the new requirements then worked:
pip install -r src/requirements.txt
answered Jan 21, 2021 at 15:49
2
Try to re-install the pip
use curl command to download the get-pip.py file:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
if curl is not working then open this link :
get-pip.py
create a get-pip.py file in your directory
copy the code from this link and put it in the get-pip.py file and save the file in the same directory.
then run the command
python get-pip.py
answered Apr 12, 2021 at 10:12
2
If you get «No module named pip» in ubuntu, try this.
$python3 -m pip --version
/usr/bin/python3: No module named pip
$sudo apt-get install python3-pip
It worked for me.
After successful installation validate using
$python3 -m pip --version
To upgrade to latest pip version
$python3 -m pip install --upgrade pip
answered Jun 2, 2021 at 1:58
VijayVijay
791 silver badge1 bronze badge
1
Use:
python -m ensurepip --user
This if your Mac is not above macOS v11 (Big Sur) and you installed Python 3. I did this and I don’t have any problems now. Back to the legacy version of 2.7 I guess.
answered Aug 21, 2022 at 22:25
1
I ran into this same issue when I attempted to install the nova client.
spencers-macbook-pro:python-novaclient root# python setup.py install
running install
/usr/bin/python: No module named pip
error: /usr/bin/python -m pip.__init__ install 'pbr>=0.5.21,<1.0' 'iso8601>=0.1.4' 'PrettyTable>=0.6,<0.8' 'requests>=1.1' 'simplejson>=2.0.9' 'six' 'Babel>=0.9.6' returned 1
I use homebrew so I worked around the issue with sudo easy_install pip
spencers-macbook-pro:python-novaclient root# brew search pip
aespipe brew-pip lesspipe pipebench pipemeter spiped pipeviewer
If you meant "pip" precisely:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
sudo easy_install pip
spencers-macbook-pro:python-novaclient root# sudo easy_install pip
The commands should be similar if you use macports.
answered Sep 9, 2013 at 19:22
spuderspuder
17.3k19 gold badges86 silver badges151 bronze badges
Download:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then Install pip:
py get-pip.py
Then Install any module, such as biopython:
py -m pip install biopython
OneCricketeer
176k18 gold badges130 silver badges239 bronze badges
answered Mar 15, 2021 at 9:31
I know this thread is old, but I just solved the problem for myself on OS X differently than described here.
Basically I reinstalled Python 2.7 through brew, and it comes with pip.
Install Xcode if not already:
xcode-select –install
Install Brew as described here:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install Python through Brew:
brew install python
And you’re done. In my case I just needed to install pyserial.
pip install pyserial
answered Aug 31, 2016 at 18:03
ScottyCScottyC
1,4571 gold badge15 silver badges22 bronze badges
1
I think none of these answers above can fix your problem.
I was also confused by this problem once. You should manually install pip
following the official guide pip installation (which currently involves running a single get-pip.py
Python script)
after that, just pip install <your package>
.
The error will be gone.
OneCricketeer
176k18 gold badges130 silver badges239 bronze badges
answered Oct 28, 2015 at 13:59
sudozsudoz
3,2051 gold badge21 silver badges19 bronze badges
2
Python3
curl -sS https://bootstrap.pypa.io/get-pip.py | python3
python3 -m pip install --upgrade pip
Just replace the python version you want in the above commands
For python 3.11 specific install
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
python3.11 -m pip install --upgrade pip
For python 3.10 specific install
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
python3.10 -m pip install --upgrade pip
For python2.7
curl -sS https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2.7
python2.7 -m pip install --upgrade pip
answered Jan 20, 2022 at 20:48
Lava SangeethamLava Sangeetham
2,8834 gold badges35 silver badges53 bronze badges
3
I downloaded pip
binaries from here and it resolved the issue.
answered Jun 11, 2014 at 8:51
MadeOfAirMadeOfAir
2,9335 gold badges31 silver badges39 bronze badges
I encountered the issue ModuleNotFoundError: No module named 'pip'
when I created a new Python 3 virtual environment using the command
python3 -m venv ~/venv/ontology ## << note: "python3" (problematic)
which is a command often suggested (here, elsewhere). When I entered that venv, pip was nowhere to be found.
In the interim, since first using that command to create Python virtual environments, my system Python had upgraded (Arch Linux system updates) from Python 3.7.4 to Python 3.9.2.
The solution is to use the command
python -m venv <your_venv> ## e.g. python -m ~/venv/ontology
When I did that (python -m ...
not python3 -m ...
), that venv now contained pip
…
To upgrade pip
within that venv, use
<your_venv_path>/bin/python -m pip install --upgrade pip
## e.g.
## /home/victoria/venv/ontology/bin/python -m pip install --upgrade pip
answered Apr 5, 2021 at 16:50
Victoria StuartVictoria Stuart
4,5022 gold badges44 silver badges36 bronze badges
In terminal try this:
ls -lA /usr/local/bin | grep pip
in my case i get:
-rwxr-xr-x 1 root root 284 Сен 13 16:20 pip
-rwxr-xr-x 1 root root 204 Окт 27 16:37 pip2
-rwxr-xr-x 1 root root 204 Окт 27 16:37 pip2.7
-rwxr-xr-x 1 root root 292 Сен 13 16:20 pip-3.4
So pip2 || pip2.7 in my case works, and pip
answered Oct 27, 2014 at 13:55
0
I am using Debian, but this solution can also be applied for Ubuntu.
- Usually, pip comes with python by default, in order to check if pip is installed in your system run.
python -m pip --version
- If pip is not there, install it using Aptitude Linux Package Manager,
# For Python 2 sudo apt install python-pip # For Python 3 sudo apt install python3-venv python3-pip
- I wouldn’t use the
get-pip.py
script in Debian/Ubuntu, because in the documentation page mentions the following.
Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
Sources here and there.
answered Apr 15, 2021 at 5:36
Here’s a minimal set of instructions for upgrading to Python 3 using MacPorts:
sudo port install py37-pip
sudo port select --set pip pip37
sudo port select --set pip3 pip37
pip install numpy, scipy, matplotlib
I ran some old code and it works again after this upgrade.
answered Oct 16, 2019 at 19:58
I was facing the same error on Windows 11, so the main problem was on executing the pip command without administrator permissions, so open up your terminal with administrator permissions and then execute the pip command again.
answered Aug 31, 2022 at 13:06
1
It is very likely that pip package was unsuccessfully updated.
You need to remove and recreate the virtual environment.
deactivate and remove virtual environment
deactivate
rm -rf [virtual_environment_name]
create a new one
python -m venv venv_name
activate it
source ./venv_name/Scripts/activate
Install the package you want:
pip install [package_name]
answered May 28 at 9:14
AbdelAbdel
493 bronze badges
I just needed to replace pip
with pip3
so I ended up running the command as follows: pip3 install matplotlib
answered Oct 1, 2020 at 20:42
1
I had a similar problem with virtualenv
that had python3.8
while installing dependencies from requirements.txt
file. I managed to get it to work by activating the virtualenv
and then running the command python -m pip install -r requirements.txt
and it worked.
answered Oct 16, 2020 at 5:44
AsimAsim
5334 silver badges19 bronze badges
I solved a similar error on Linux by setting PYTHONPATH to the site-packages location. This was after running python get-pip.py --prefix /home/chet/pip
.
[chet@rhel1 ~]$ ~/pip/bin/pip -V
Traceback (most recent call last):
File "/home/chet/pip/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named pip
[chet@rhel1 ~]$ export PYTHONPATH=/home/chet/pip/lib/python2.6/site-packages
[chet@rhel1 ~]$ ~/pip/bin/pip -V
pip 9.0.1 from /home/chet/pip/lib/python2.6/site-packages (python 2.6)
answered Oct 24, 2017 at 21:54
GargantuChetGargantuChet
5,6811 gold badge30 silver badges41 bronze badges
Tested below for Linux:
You can directly download pip from https://pypi.org/simple/pip/
untar and use directly with your latest python.
tar -xvf pip-0.2.tar.gz
cd pip-0.2
Check for the contents.
anant$ ls
docs pip.egg-info pip-log.txt pip.py PKG-INFO regen-docs scripts setup.cfg setup.py tests
Execute directly:
anant$ python pip.py --help
Usage: pip.py COMMAND [OPTIONS]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-E DIR, --environment=DIR
virtualenv environment to run pip in (either give the
interpreter or the environment base directory)
-v, --verbose Give more output
-q, --quiet Give less output
--log=FILENAME Log file where a complete (maximum verbosity) record
will be kept
--proxy=PROXY Specify a proxy in the form
user:passwd@proxy.server:port. Note that the
user:password@ is optional and required only if you
are behind an authenticated proxy. If you provide
user@proxy.server:port then you will be prompted for a
password.
--timeout=SECONDS Set the socket timeout (default 15 seconds)
answered Oct 1, 2019 at 10:42
my py version is 3.7.3, and this cmd worked
python3.7 -m pip install requests
requests library — for retrieving data from web APIs.
This runs the pip module and asks it to find the requests library on PyPI.org (the Python Package Index) and install it in your local system so that it becomes available for you to import
answered May 1, 2019 at 13:25
MahiMahi
4725 silver badges7 bronze badges
1
Проблема такая, нужно было установить pyinstaller через pip, оно не устанавливалось, нашел в интернете ответ такой, что надо откатить pip на раннюю версию, сделал по команде котору привел человек в итоге теперь пишет мне no module named ‘pip’ как быть? Как вернуть pip?
вот данный ответ, который я нашел:
Откати версию PIP до 18.1
pip install pip==18.1
Пробуй установить pyinstaller еще раз
pip install pyinstaller
Обнови версию PIP до последней
python -m pip install –upgrade pip
вот ошибка полная Traceback (most recent call last): File «d:valerapythonlibrunpy.py», line 193, in run_module_as_main «main», mod_spec) File «d:valerapythonlibrunpy.py», line 85, in _run_code exec(code, run_globals) File «D:ValeraPythonScriptspip.exe__main_.py», line 5, in ModuleNotFoundError: No module named ‘pip’
Environment
- pip version: 9.0.3
- Python version: 3.6
- OS: Windows Server 2016 Datacenter
Description
My system admin installed Python 3.6 for me in my AWS workspace and i requested him to update the pip version to 18 but while he was trying to upgrade the version, he ran into error. All below-mentioned commands were executed from a Powershell window in Administrative mode:
Output
PS D:python3.6scripts> pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940
/pip-18.0-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 720kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Exception:
Traceback (most recent call last):
File "d:python3.6libshutil.py", line 544, in move
os.rename(src, real_dst)
OSError: [WinError 17] The system cannot move the file to a different disk drive: 'd:\python\3.6\scripts\pip.exe' ->
'C:\Users\sdgadmin\AppData\Local\Temp\pip-o9ithn08-uninstall\python\3.6\scripts\pip.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:python3.6libsite-packagespipbasecommand.py", line 215, in main
File "d:python3.6libsite-packagespipcommandsinstall.py", line 342, in run
File "d:python3.6libsite-packagespipreqreq_set.py", line 778, in install
File "d:python3.6libsite-packagespipreqreq_install.py", line 754, in uninstall
File "d:python3.6libsite-packagespipreqreq_uninstall.py", line 115, in remove
File "d:python3.6libsite-packagespiputils__init__.py", line 267, in renames
File "d:python3.6libshutil.py", line 559, in move
os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'd:\python\3.6\scripts\pip.exe'
PS D:python3.6scripts> pip list
Traceback (most recent call last):
File "d:python3.6librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:python3.6librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:Python3.6Scriptspip.exe__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:python3.6scripts> pip3 install --upgrade pip
Traceback (most recent call last):
File "d:python3.6librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:python3.6librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:Python3.6Scriptspip3.exe__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:python3.6scripts> pip3 install --upgrade pip3
Traceback (most recent call last):
File "d:python3.6librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:python3.6librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:Python3.6Scriptspip3.exe__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:python3.6scripts> pip install --upgrade pip
Traceback (most recent call last):
File "d:python3.6librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:python3.6librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:Python3.6Scriptspip.exe__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:python3.6scripts> pip.exe install --upgrade pip
Traceback (most recent call last):
File "d:python3.6librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:python3.6librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:Python3.6Scriptspip.exe__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
Are we doing something wrong here? I also checked few links that suggested using easy_install. I tried that as well but ran into issues.
PS D:python3.6scripts> .easy_install.exe pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
d:python3.6libsite-packagessetuptoolspep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python
ABI tag may be incorrect
warn=(impl == 'cp')):
d:python3.6libsite-packagessetuptoolspep425tags.py:93: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, P
ython ABI tag may be incorrect
warn=(impl == 'cp')):
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/p
ip-18.0-py2.py3-none-any.whl#sha256=070e4bf493c7c2c9f6a08dd797dd3c066d64074c38e9e8a0fb4e6541f266d96c
error: Download error for https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3
703d2ddaf940/pip-18.0-py2.py3-none-any.whl#sha256=070e4bf493c7c2c9f6a08dd797dd3c066d64074c38e9e8a0fb4e6541f266d96c: [SSL
: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
One error that you might encounter while using Python is:
ModuleNotFoundError: No module named 'pip'
This error occurs when the pip
module is not available in your Python environment.
This tutorial shows an example that causes this error and how to fix it.
How to reproduce the error
Suppose you want to import the pip
module in your source code as follows:
import pip
print(pip.__version__)
But you get the following error when running the code:
Traceback (most recent call last):
File "main.py", line 1, in <module>
import pip
ModuleNotFoundError: No module named 'pip'
This error occurs when the pip
module is not available in your Python environment.
The pip
module is usually bundled with Python, so it should be available when you installed the Python program.
But if you see this error, then Python might have skipped building the pip
module when you install it.
How to fix this error
To resolve this error, you need to install the pip
module using the ensurepip
module.
Try to run one of the commands below:
python -m ensurepip
# For Python 3:
python3 -m ensurepip
# Windows:
py -m ensurepip
# For Linux, you can also use:
sudo apt install python3-pip
Once the module is installed, run one of the following commands to see if pip
is available:
pip -V
pip3 -V
# If pip not available in PATH, try:
python -m pip -V
python3 -m pip -V
If the command works, then you should be able to import pip
in your source code without receiving the error.
Alternative ways to install pip
If the command above doesn’t work, you can try using the get-pip.py
script to install the module.
First, download the script from https://bootstrap.pypa.io/get-pip.py into your computer. You need to open the context menu with right-click and select the ‘Save As..’ option.
Next, run the get-pip.py
script using Python from your terminal as follows:
python get-pip.py
# For Python 3:
python3 get-pip.py
# Windows:
py get-pip.py
You should have a similar output as follows:
You should be able to run pip
or pip3
from the terminal now.
If you still can’t access pip
, then try to install the module using commands specific to your Operating System:
# For Debian / Ubuntu
sudo apt update
sudo apt install python3-venv python3-pip
# For Fedora
sudo dnf update
sudo dnf install python3-pip python3-wheel
# For CentOS / RHEL
sudo yum update
sudo yum install python3 python3-pip
If you’re using Windows or macOS, you need to reinstall Python using the official installer, which should also take care of adding pip
to the system PATH.
Adding pip to PATH
If you can’t run pip -V
but able to run python -m pip -V
, that means the path to pip is not added to your PATH system.
In Windows, you can do this using the set PATH
command.
Get the location of Python using the where python
command as follows:
Output:
where python
C:UsersnsebhastianAppDataLocalProgramsPythonPython310python.exe
C:UsersnsebhastianAppDataLocalMicrosoftWindowsAppspython.exe
Next, add the location to python.exe
to your PATH as follows:
set PATH=%PATH%;C:UsersnsebhastianAppDataLocalProgramsPythonPython310
That should allow the command prompt to find the pip
module for the current session. If you want to add the location permanently to the PATH, use the setx
command instead of set
.
For Linux and macOS, run the export PATH
command followed by the $PATH
variable:
export PATH="$PATH:/usr/local/bin/python"
You need to add the absolute path to the Python location as well.
Conclusion
The ModuleNotFoundError: No module named 'pip'
occurs in Python when the pip
module is not available in the current Python environment.
To resolve this error, run the ensurepip
or get-pip.py
script that will install pip
to your system.
I hope this tutorial is helpful. See you in other tutorials! 👍
PIP is a widely used Python package manager to manage and perform various operations. For instance, installing, removing, upgrading, and downgrading specific packages in Python.
However, if this module is not correctly installed in the system, the error named “ModuleNotFoundError” occurs in Python.
This write-up will explain the possible reasons and appropriate solutions for the “no module named pip” error in python using the following snippet:
- Reason: pip Not Installed
- Solution 1: Install pip Using ensurepip Command (Windows)
- Solution 2: Install pip Using get-pip.py (Windows)
- Solution 3: Installing pip on Linux
- How to Upgrade the pip Version?
- How to Downgrade the pip Version?
Reason: pip Not Installed
A common reason for the “ModuleNotFoundError: No module named pip” in Python is that the “pip” is not installed in the Python environment. The snippet below shows the stated error:
The above snippet shows that the “pip” module is not installed in our system.
Solution 1: Install pip Using ensurepip Command (Windows)
Open the command prompt and enter the following command to install the pip package:
> py -m ensurepip --upgrade
The below snippet shows that the pip version “21.2.3” has been successfully installed:
Solution 2: Install pip Using get-pip.py (Windows)
We can also install pip in our system using the bootstrapping logic method. For this, open the command prompt terminal and type the following command to download the “get-pip.py” file:
> curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
After downloading the “get-pip.py” file, the next thing is to install pip on windows using the given below command:
As you can see in the below snippet, the “pip-22.3.1” latest version installed in Python successfully:
Verify the Installation of pip (Windows)
In our system, we can check whether pip is correctly installed. First, enter the Python shell using the “python” command in CMD and after that, run the “import pip” command:
Solution 3: Installing pip on Linux
To install Python pip on “Ubuntu 22.04” you can follow the given below detailed tutorial: How to Install Python Pip on Ubuntu 22.04
To install Python pip on various other Linux distributions, for example, to install Python pip on Arch Linux type the given below commands in the terminal:
# Python 2 $ sudo pacman -S python2-pip # Python 3 $ sudo pacman -S python-pip
To install Python pip on Fedora, type the following command:
# Python 2 $ sudo dnf install python-pip # Python 3 $ sudo dnf install python3
Similarly to install Python pip package manager on CentOS and RHEL use the given below command:
$ sudo yum install epel-release #enabling the repository $ sudo yum install python-pip
How to Upgrade the pip Version?
To upgrade the pip package in the system, the first step is to check the current version of the “pip module” by typing the following command:
The above snippet shows that the pip version “22.3.1” is installed in our system.
To upgrade the pip package in Python, the following command is used in Python:
> python -m pip install --upgrade pip
From the above snippet, it is verified that the “pip” package installed in our system is up to date.
How to Downgrade the pip Version?
To downgrade or install the specific pip version, we use the following command in terminal windows (command prompt):
> python -m pip install pip==18.1
As we can see from the below snippet that version “18.1” is successfully installed. The previous version was successfully removed from the system:
Conclusion
The “ModuleNotFoundError: No module named pip” occurs in Python when the “pip” package is not installed in our system. To rectify this error, various methods are used to install “pip” such as using the official Python installer, using the “ensurepip” command, and using get-pip.py. The various solutions for installing pip in different Linux distributions are also provided in this article. Apart from that, the methods to upgrade or downgrade the pip version is also provided.