我的操作系统:赢10
已安装:
python
)python3
)pip命令:
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'
我通过pip
安装了xlwt,我可以看到它已安装:
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)
然而,当我尝试导入它时,得到了错误: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()
此外,我成功地使用了pip3 install xlwt
,但运行python3 ... import xlwt
失败。完整日志:
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'
>>>
如何解决这个问题
我应该为python/pip配置windows路径还是什么
谢谢
编辑:
也许我安装了多个python3
执行
python3 -m pip install xlwt
,这总是为python3
安装(当您在终端中执行python3
时启动python),那么应该可以在python3
中导入已安装的模块。如果你想知道更多关于这方面的信息,请阅读Installing Python Modules in docs好的,我终于找到了根本原因
我的电脑中有两个python版本:
我相信这两个版本的配置之间存在一些冲突。(例如执行路径、pip路径等)导致
pip install
工作不正常解决方案非常简单:卸载所有python版本并重新安装3.7,一切都很顺利
在python控制台中,您的python版本是2.7。 更改为python 3.9版本
相关问题 更多 >
编程相关推荐