[英]Python does not find installed modules
Python3.5 does not locate installed modules when invoked in virtual env. Python3.5 在虚拟环境中调用时不会定位已安装的模块。
python3.5 -m venv autogit/venv && cd autogit
python3.5 -m venv autogit/venv && cd autogit
source venv/bin/activate
which python
== ...autogit/venv/bin/python
Weird, would expect python3.5 which python
== ...autogit/venv/bin/python
奇怪,期望 python3.5/autogit
and pip freeze>requirements.txt
/autogit
和pip freeze>requirements.txt
pip install -r requirements.txt
ls venv/lib/python3.5/site-packages
shows request-0-0-0-py3.5.egg-info
and some other stuff ls venv/lib/python3.5/site-packages
显示request-0-0-0-py3.5.egg-info
和其他一些东西which python
revealed python rather than python3.5
, lets invoke the python3.5binary explicitly.... venv/bin/python3.5 autogit.py
Get ImportError: No module named 'request
which python
显示 python 而不是python3.5
,让我们显式调用 python3.5binary.... venv/bin/python3.5 autogit.py
Get ImportError: No module named 'request
??? ??? Where could python be looking for packages if not in my virtual env?
如果不在我的虚拟环境中,python 可以在哪里寻找包?
UPDATE The questions above remain unanswered;更新上述问题仍未得到解答; here are things I noticed since then and the workaround I used:
以下是我从那时起注意到的事情以及我使用的解决方法:
pip install
produced a file request-0-0-0-py3.5.egg-info
. pip install
产生了一个文件request-0-0-0-py3.5.egg-info
。 It did NOT produce an actual request
directory with the source code or binaries for this module.它没有生成包含该模块的源代码或二进制文件的实际
request
目录。 Also why is it version 0 0 0 that is fishy还有为什么版本 0 0 0 是可疑的
After some googling I noticed the module I wanted seemed to be named requests
not request
which is what was in my source.经过一番谷歌搜索后,我注意到我想要的模块似乎被命名为
requests
而不是request
,这是我的源代码中的内容。 I changed it requests, pip install
, and everything works.我改变了它的请求,
pip install
,一切正常。 It was hard to see that there was a mistake because pip install
ing request
did not fail很难看出有错误,因为
pip install
ing request
没有失败
Have you got other Python versions installed?您是否安装了其他 Python 版本? That might be the problem.
这可能是问题所在。
Try using pip3
instead of pip
尝试使用
pip3
而不是pip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.