I have installed pip and ez setup. I also checked the system path and I can see the module in the folder structure. Still when i try to run pip command, I get an Import error saying no module named pip. I am running 32bit python on a windows7 machine
asked Sep 17, 2015 at 20:07
1
Just be sure that you have include python to windows PATH variable, then run python -m ensurepip
answered Mar 1, 2017 at 12:13
7
After running get_pip.py
with python embed you have to modify your pythonXX._pth
file. Add Libsite-packages
, to get something like this:
pythonXX.zip
.
Libsite-packages
# Uncomment to run site.main() automatically
#import site
If you don’t you will get this error:
ModuleNotFoundError: No module named ‘pip’
or
python-3.8.2-embed-amd64python.exe: No module named pip
λ pip
Traceback (most recent call last):
File "runpy.py", line 193, in _run_module_as_main
File "runpy.py", line 86, in _run_code
File "python-3.8.2-embed-amd64Scriptspip.exe__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
λ python -m pip
python-3.8.2-embed-amd64python.exe: No module named pip
answered Mar 24, 2020 at 10:48
user2226755user2226755
12.3k5 gold badges50 silver badges73 bronze badges
5
This issue occurs with me while I was trying to upgrade pip version.
It was resolved with the following commands:
python -m ensurepip
The above command restores the pip and below mentioned upgrades it.
python -m pip install --upgrade pip
answered Dec 9, 2020 at 20:06
raven404raven404
1,0118 silver badges14 bronze badges
2
What solved the issue on my case was go to:
cd C:Program FilesPython37Scripts
And run below command:
easy_install.exe pip
answered Apr 10, 2019 at 12:51
3
try to type pip3 instead pip.
also for upgrading pip dont use pip3 in the command
python -m pip install -U pip
maybe it helps
answered Dec 17, 2016 at 19:43
SetmaxSetmax
9466 silver badges10 bronze badges
turned out i had 2 versions of python on my laptop
both commands worked for me
python -m ensurepip
py -m ensurepip
both with another installation path
c:toolspythonlibsite-packages
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packages
only the first path was in my %PATH% variable
answered Nov 27, 2018 at 8:55
SloomySloomy
1511 silver badge6 bronze badges
0
First make sure that python
is added in environment variable.
Try checking the version of pip
or pip3
. Use these commands to check.
For pip
:
pip --version
For pip3
:
pip3 --version
If you can see any version of pip and still not able to use it, then run the following command.
python -m ensurepip
This ensures the pip
in your system.
answered Apr 3, 2022 at 18:18
I found this post while looking for a solution for the same problem. I was using an embedded python distribution. In this case, the solution is to uncomment import site
in the file python<version>._pth
.
answered Jul 29, 2021 at 12:52
canbooocanbooo
711 silver badge3 bronze badges
0
Running these 2 commands helped me:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
answered Sep 25, 2020 at 21:02
DeviljeeDeviljee
711 silver badge4 bronze badges
If you wrote
pip install --upgrade pip
and you got
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.1
Uninstalling pip-20.2.1:
ERROR: Could not install packages due to an EnvironmentError...
then you have uninstalled pip instead install pip.
This could be the reason of your problem.
The Gorodeckij Dimitrij’s answer works for me.
python -m ensurepip
answered Oct 13, 2020 at 14:49
negasnegas
81112 silver badges10 bronze badges
The ensurepip
module was added in version 3.4 and then backported to 2.7.9.
So make sure your Python version is at least 2.7.9 if using Python 2, and at least 3.4 if using Python 3.
answered Feb 12, 2018 at 20:38
twasbrilligtwasbrillig
16.7k9 gold badges43 silver badges66 bronze badges
I’v solved this error by setting the correct path variables
C:UsersnameAppDataLocalProgramsPythonPython37Scripts
C:UsersnameAppDataLocalProgramsPythonPython37Libsite-packages
answered Jul 23, 2019 at 7:40
PratikPalPratikPal
511 silver badge3 bronze badges
I was facing same issue and resolved using following steps
1) Go to your paython package and rename «python37._pth» to python37._pth.save
2) curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
3) then run python get-pip.py
4) pip install django
Hope this help
answered Sep 15, 2019 at 5:13
vaquar khanvaquar khan
10.7k5 gold badges72 silver badges94 bronze badges
I’ve solved this error downloading the executable file for python 3.7.
I’ve had downloaded the embeddeable version and got that error.
Now it works!
answered Oct 16, 2018 at 2:07
The method I’m going to tell might not be the correct way to do it. But this method solved my issue. I tried every solution on youtube and StackOverflow methods.
-
If you have two python versions installed. Delete one. I have the python 3.8.1 and 3.9.0 versions installed. I deleted version 3.9.0 from the C directory.
-
Now go to the control panel > System and security > System > Advanced system settings.
Click on ‘environment variables’.
Select the path and click on ‘edit’
Now, add the path of the python and also the path of pip module. In my case it was c:python38 and c:python38scripts
This method solved my issue.
answered Feb 14, 2021 at 12:43
Instead of Python zip install python by python installer. It fixed the issue for me.
answered Aug 2, 2022 at 11:04
Проблема такая, нужно было установить 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’
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
175k18 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,7051 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,3362 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,1321 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.2k19 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
175k18 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
175k18 gold badges130 silver badges239 bronze badges
answered Oct 28, 2015 at 13:59
sudozsudoz
3,1951 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,8734 gold badges34 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,4922 gold badges43 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
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,6711 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
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
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
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! 👍
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)