My OS: win 10,
installed:
python
) python3
) pip command:
c:\>pip3 config list -v
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\luelue\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\luelue\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'c:\users\luelue\appdata\local\programs\python\python39\pip.ini'
c:\>pip config list -v
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\luelue\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\luelue\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'c:\users\luelue\appdata\local\programs\python\python39\pip.ini'
I installed xlwt via pip
, and I can see it's installed:
c:\>pip install xlwt
Requirement already satisfied: xlwt in c:\users\luelue\appdata\local\programs\python\python39\lib\site-packages\xlwt-1.3.0-py3.9.egg (1.3.0)
However, when I try to import it, got error: No module named xlwt
c:\>python
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlwt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xlwt
>>> exit()
Also, I used pip3 install xlwt
successfully, but run python3... import xlwt
failed. full log:
C:\files\dong_tai_pai_fang_ji_suan\python_code>pip3 install xlwt
Requirement already satisfied: xlwt in c:\users\luelue\appdata\local\programs\python\python39\lib\site-packages\xlwt-1.3.0-py3.9.egg (1.3.0)
C:\files\dong_tai_pai_fang_ji_suan\python_code>python3
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlwt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'xlwt'
>>>
how to resolve this?
should I configure the windows PATH or something for python/pip?
thanks
edit:
your python version is 2.7 in python console. change to python 3.9 version.
maybe I installed multiple python3
Do python3 -m pip install xlwt
, this always install for python3
(python launched when you do python3
in terminal), then it should be possible to import installed module in python3
. If you want to know more about that read Installing Python Modules in docs .
OK at last I find the root cause.
There are 2 versions of python in my PC:
and I believe there are some conflicts between these two version's configuration. ( eg execute path, pip path, etc ) which makes pip install
work incorrectly.
solution is quite simple: uninstall all the python version and re-install 3.7, everything goes well!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.