Please help me to find reason on MacOS why when I including library
import wget
I'm getting error
File "/Users/xx/python/import.py", line 4, in <module>
import wget
ImportError: No module named wget
This library is installed
xx$ pip3 install wget
Requirement already satisfied: wget in /usr/local/lib/python3.6/site-packages (3.2)
I just suppose that some path is not set, but I don't know how to prove this.
Please help me find solution for this problem.
8 Answers
Try pip install wget, maybe you’re using python 2
With pip3 you are installing module for python 3, It can b that you have both versions of python 2 and 3 and you your environment is pointing default to python 2
Check python version or install wget for python 2
python -V
pip install wget
this should not be the case, but check if site-packages is in the path for accessing modules
>>> import sys
>>> sys.path
[..., '...\\python3.6\\lib\\site-packages', ...] ## if this is here I cannot help you
if not, try repairing python
you can do that by clicking setup file (one with which you installed in the first place),
and among 3 options click repair
sudo apt-get install --reinstall python3-wget
If you process the python script by command:
python import.py
or
python3 import.py
it should work.
But if you process the executable python script by command:
./import.py ENTER
then incldue as the first line of the script import.py:
#!/usr/bin/env python
or
#!/usr/bin/env python3
The following command worked for me in Jupyter Lab
!pip install wget
Hope this does help!
In Jupyter Lab, although my Python was 3.9 but it was using 3.7 paths (I have multiple Pythons installed):
import sys
sys.path
['D:\\Projects',
'C:\\Program Files\\Python37\\python37.zip',
'C:\\Program Files\\Python37\\DLLs',
'C:\\Program Files\\Python37\\lib',
'C:\\Program Files\\Python37',
'',
'C:\\Users\\John\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Program Files\\Python37\\lib\\site-packages',
'C:\\Program Files\\Python37\\lib\\site-packages\\win32',
'C:\\Program Files\\Python37\\lib\\site-packages\\win32\\lib',
'C:\\Program Files\\Python37\\lib\\site-packages\\Pythonwin',
'C:\\Program Files\\Python37\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\John\\.ipython']
So I did !pip3.7 install --user wget, and then it worked.
pip install wget
if in colab use:
!pip install wget