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 the pip command, I get an Import error saying no module named pip. I am running 32-bit Python on a Windows 7 machine.
asked Sep 17, 2015 at 20:07
1
Just be sure that you have included the Python executable in the Windows Environment Variables, System PATH variable, and then run:
python -m ensurepip
.
or if you have permission issue, run:
python -m ensurepip --user
blackraven
5,2947 gold badges19 silver badges45 bronze badges
answered Mar 1, 2017 at 12:13
8
After running get_pip.py
with Python embed, you have to modify your pythonXX._pth
file. Add Lib\site-packages
, to get something like this:
pythonXX.zip
.
Lib\site-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-amd64\python.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-amd64\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
λ python -m pip
python-3.8.2-embed-amd64\python.exe: No module named pip
answered Mar 24, 2020 at 10:48
user2226755user2226755
12.5k5 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,0499 silver badges14 bronze badges
2
What solved the issue on my case was go to:
cd C:\Program Files\Python37\Scripts
And run below command:
easy_install.exe pip
answered Apr 10, 2019 at 12:51
3
Try to type pip3 instead of pip.
Also for upgrading pip, don’t use pip3 in the command
python -m pip install -U pip
answered Dec 17, 2016 at 19:43
SetmaxSetmax
9667 silver badges11 bronze badges
It turned out I had two versions of the Python executable on my laptop.
Both commands worked for me
python -m ensurepip
py -m ensurepip
Both with another installation path
c:\tools\python\lib\site-packages
c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-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 badge5 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
86112 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
17.2k9 gold badges43 silver badges67 bronze badges
I’v solved this error by setting the correct path variables
C:\Users\name\AppData\Local\Programs\Python\Python37\Scripts
C:\Users\name\AppData\Local\Programs\Python\Python37\Lib\site-packages
answered Jul 23, 2019 at 7:40
PratikPalPratikPal
511 silver badge3 bronze badges
I was facing the same issue and resolved it using the following steps.
-
Go to your Python package and rename «python37._pth» to python37._pth.save
-
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
-
then run
python get-pip.py
-
pip install django
answered Sep 15, 2019 at 5:13
vaquar khanvaquar khan
10.9k5 gold badges73 silver badges96 bronze badges
1
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
Instead of Python zip install python by python installer. It fixed the issue for me.
answered Aug 2, 2022 at 11:04
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 Stack Overflow 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 executable and also the path of pip module. In my case it was C:\python38 and C:\python38\scripts.
This method solved my issue.
answered Feb 14, 2021 at 12:43
Here i need to do this things:
1 — Redownload python 3.9 (https://www.python.org/ftp/python/3.9.0/python-3.9.0.exe)
2 — Reinstall
3 — Edit the file python3.9._pth
C:\Laragon\bin\python\python-3.9.0
C:\Laragon\bin\python\python-3.9.0\DLLs
C:\Laragon\bin\python\python-3.9.0\Lib
C:\Laragon\bin\python\python-3.9.0\Lib\plat-win
C:\Laragon\bin\python\python-3.9.0\Lib\site-packages
# Uncomment to run site.main() automatically
#import site
4 — run the command «python -m pip install requests»
answered Jun 11 at 21:51
Usally upgrading the pipline will solve the problem, when upgrading check that you have the permission (in case you are working from Command Line)
python.exe -m pip install --upgrade pip
answered Jul 30 at 11:34
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 the pip command, I get an Import error saying no module named pip. I am running 32-bit Python on a Windows 7 machine.
asked Sep 17, 2015 at 20:07
1
Just be sure that you have included the Python executable in the Windows Environment Variables, System PATH variable, and then run:
python -m ensurepip
.
or if you have permission issue, run:
python -m ensurepip --user
blackraven
5,2947 gold badges19 silver badges45 bronze badges
answered Mar 1, 2017 at 12:13
8
After running get_pip.py
with Python embed, you have to modify your pythonXX._pth
file. Add Lib\site-packages
, to get something like this:
pythonXX.zip
.
Lib\site-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-amd64\python.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-amd64\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
λ python -m pip
python-3.8.2-embed-amd64\python.exe: No module named pip
answered Mar 24, 2020 at 10:48
user2226755user2226755
12.5k5 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,0499 silver badges14 bronze badges
2
What solved the issue on my case was go to:
cd C:\Program Files\Python37\Scripts
And run below command:
easy_install.exe pip
answered Apr 10, 2019 at 12:51
3
Try to type pip3 instead of pip.
Also for upgrading pip, don’t use pip3 in the command
python -m pip install -U pip
answered Dec 17, 2016 at 19:43
SetmaxSetmax
9667 silver badges11 bronze badges
It turned out I had two versions of the Python executable on my laptop.
Both commands worked for me
python -m ensurepip
py -m ensurepip
Both with another installation path
c:\tools\python\lib\site-packages
c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-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 badge5 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
86112 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
17.2k9 gold badges43 silver badges67 bronze badges
I’v solved this error by setting the correct path variables
C:\Users\name\AppData\Local\Programs\Python\Python37\Scripts
C:\Users\name\AppData\Local\Programs\Python\Python37\Lib\site-packages
answered Jul 23, 2019 at 7:40
PratikPalPratikPal
511 silver badge3 bronze badges
I was facing the same issue and resolved it using the following steps.
-
Go to your Python package and rename «python37._pth» to python37._pth.save
-
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
-
then run
python get-pip.py
-
pip install django
answered Sep 15, 2019 at 5:13
vaquar khanvaquar khan
10.9k5 gold badges73 silver badges96 bronze badges
1
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
Instead of Python zip install python by python installer. It fixed the issue for me.
answered Aug 2, 2022 at 11:04
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 Stack Overflow 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 executable and also the path of pip module. In my case it was C:\python38 and C:\python38\scripts.
This method solved my issue.
answered Feb 14, 2021 at 12:43
Here i need to do this things:
1 — Redownload python 3.9 (https://www.python.org/ftp/python/3.9.0/python-3.9.0.exe)
2 — Reinstall
3 — Edit the file python3.9._pth
C:\Laragon\bin\python\python-3.9.0
C:\Laragon\bin\python\python-3.9.0\DLLs
C:\Laragon\bin\python\python-3.9.0\Lib
C:\Laragon\bin\python\python-3.9.0\Lib\plat-win
C:\Laragon\bin\python\python-3.9.0\Lib\site-packages
# Uncomment to run site.main() automatically
#import site
4 — run the command «python -m pip install requests»
answered Jun 11 at 21:51
Usally upgrading the pipline will solve the problem, when upgrading check that you have the permission (in case you are working from Command Line)
python.exe -m pip install --upgrade pip
answered Jul 30 at 11:34
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:\python\3.6\scripts> 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:\python\3.6\lib\shutil.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:\python\3.6\lib\site-packages\pip\basecommand.py", line 215, in main
File "d:\python\3.6\lib\site-packages\pip\commands\install.py", line 342, in run
File "d:\python\3.6\lib\site-packages\pip\req\req_set.py", line 778, in install
File "d:\python\3.6\lib\site-packages\pip\req\req_install.py", line 754, in uninstall
File "d:\python\3.6\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
File "d:\python\3.6\lib\site-packages\pip\utils\__init__.py", line 267, in renames
File "d:\python\3.6\lib\shutil.py", line 559, in move
os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'd:\\python\\3.6\\scripts\\pip.exe'
PS D:\python\3.6\scripts> pip list
Traceback (most recent call last):
File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\3.6\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:\python\3.6\scripts> pip3 install --upgrade pip
Traceback (most recent call last):
File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\3.6\Scripts\pip3.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:\python\3.6\scripts> pip3 install --upgrade pip3
Traceback (most recent call last):
File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\3.6\Scripts\pip3.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:\python\3.6\scripts> pip install --upgrade pip
Traceback (most recent call last):
File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\3.6\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
PS D:\python\3.6\scripts> pip.exe install --upgrade pip
Traceback (most recent call last):
File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\3.6\Scripts\pip.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:\python\3.6\scripts> .\easy_install.exe pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
d:\python\3.6\lib\site-packages\setuptools\pep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python
ABI tag may be incorrect
warn=(impl == 'cp')):
d:\python\3.6\lib\site-packages\setuptools\pep425tags.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:\Users\nsebhastian\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\nsebhastian\AppData\Local\Microsoft\WindowsApps\python.exe
Next, add the location to python.exe
to your PATH as follows:
set PATH=%PATH%;C:\Users\nsebhastian\AppData\Local\Programs\Python\Python310
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! 👍
This error occurs when you try to use pip, but it is not installed in your Python environment. This can happen if you skip installing pip when installing Python or when creating a virtual environment, or after explicitly uninstalling pip.
You can solve this error by downloading pip using the following curl command
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then install pip by running:
python3 get-pip.py
If this does not work, you can use ensurepip to bootstrap the pip installer into an existing Pip installation or virtual environment. For example,
# Linux python3 -m ensurepip --upgrade # MacOS python3 -m ensurepip --upgrade # Windows py -m ensurepip --upgrade
This tutorial will go through the ways to ensure pip is installed in your environment.
Table of contents
- Install pip by Downloading get-pip.py
- Bootstrap pip using ensurepip
- Install pip using Operating System Specific command
- Installing pip for Linux
- Installing pip for Mac Operating System
- Upgrading pip
- Check pip and Python version
- Recreate Virtual Environment
- Summary
Install pip by Downloading get-pip.py
Download pip by running the following curl command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
The curl
command allows you to specify a direct download link. Using the -o
option sets the name of the downloaded file.
Install pip by running:
python3 get-pip.py
Bootstrap pip using ensurepip
You can use ensurepip to bootstrap the pip installer into an existing Pip installation or virtual environment. For example,
# Linux python3 -m ensurepip --upgrade # MacOS python3 -m ensurepip --upgrade # Windows py -m ensurepip --upgrade
Install pip using Operating System Specific command
If the above solutions do not work, you can try to install pip using the command specific to your operating system.
Installing pip for Linux
All major Linux distributions have Python installed by default. However, you will need to install pip. You can install pip from the terminal, but the installation instructions depend on the Linux distribution you are using. You will need root privileges to install pip. Open a terminal and use the commands relevant to your Linux distribution to install pip.
Installing pip for Ubuntu, Debian, and Linux Mint
sudo apt install python-pip3
Installing pip for CentOS 8 (and newer), Fedora, and Red Hat
sudo dnf install python-pip3
Installing pip for CentOS 6 and 7, and older versions of Red Hat
sudo yum install epel-release sudo yum install python-pip3
Installing pip for Arch Linux and Manjaro
sudo pacman -S python-pip
Installing pip for OpenSUSE
sudo zypper python3-pip
Installing pip for Mac Operating System
You can install Python3 and pip3 using brew with the following command:
brew install python
Upgrading pip
You may also need to upgrade pip, which you can do with the following commands:
# Linux python3 -m pip install --upgrade pip # MacOS python3 -m pip install --upgrade pip # Windows py -m pip install --upgrade pip
Check pip and Python version
Ensure that the Python version in use matches the pip version. You can check versions from the command line using the --version
flag. For example,
python --version
Python 3.8.8
pip --version
pip 21.2.4 from /Users/Research/opt/anaconda3/lib/python3.8/site-packages/pip (python 3.8)
Note that the –version returns the version of Python is 3.8.8, and the pip installer in use is for 3.8.
Recreate Virtual Environment
If you are using a virtual environment and the error persists despite trying the above solutions, you can recreate the environment. For example,
# deactivate environment deactivate # remove the virtual environment folder rm -rf venv # Initial a new virtual environment python3 -m venv venv # Activate on Linux/MacOS source venv/bin/activate # Activate on Windows (cmd.exe) venv\Scripts\activate.bat # Activate on Windows (PowerShell) venv\Scripts\Activate.ps1
Summary
Congratulations on reading to the end of this tutorial.
Go to the online courses page on Python to learn more about Python for data science and machine learning.
For further reading on missing modules in Python, go to the article:
- How to Solve ModuleNotFoundError: no module named ‘plotly’.
- How to Solve Python ModuleNotFoundError: no module named ‘pymongo’
- How to Solve Python ModuleNotFoundError: no module named ‘xgboost’
Have fun and happy researching!