所以昨天我不得不创建一个virtualenv,以便能够安装由于osx El Capitan的新SIP而无法安装的Python模块。我以为我做的每件事都对,但今天我得出了不同的结论。我希望我能说清楚。你知道吗
我的python自定义安装在myname/learnp/imdb\u模块,这是我用virtualenv创建它的地方。编辑:我后来把它移到myname/learnp/ayr2/imdb\u模块。你知道吗
但是,当我尝试运行解释器时,它似乎总是默认为库中的Python或类似的东西。我发现这一点是因为我在这个定制python环境中安装的某个模块无法导入,当我检查我拥有的模块时,它与我预期的不一样。你知道吗
此外,我想在定制virtualenv上安装的所有其他模块似乎都安装在主python env上,而我一直没有在定制env上安装这些模块。你知道吗
对不起,我现在很困惑。你知道吗
任何建议都非常感谢!你知道吗
更新:
跟随Will Hogan's answer进行故障排除,我认为发生了一些奇怪的事情,引用我对他的回答的评论:
HI, thanks for taking the time to answer. This is basically the way I understood this. However, let me attach a screenshot: http://i.imgur.com/DfpngJq.jpg . Am I right to assume something is wrong here? My prompt is changed with the virtualenv named "imdb_module", but when I type in
which python
it doesn't listayr2/imdb_module/bin
but rather a folder with the pathusr/bin/python
, which if I understand correctly is the "default" environment.And not if this helps in any way, but
echo $PATH
when (imdv_module) appears to the right of the prompt, gives this (I redacted my name):/Users/REDACTEDNAME/learnp/imdb_module/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
在创建virtualenv时,您应该看到它正在安装setuptools和pip:
在确保virtualenv被激活后,您应该看到您的提示更改:
现在您可以确认python和pip的路径,它们应该在virtualenv中:
如果您没有看到python和pip位置在virtualenv的目录下,那么virtualenv还没有被激活。你知道吗
我还要确保,如果您直接执行.py文件(而不是使用“
python foo.py
”),shebang行使用:甚至是到virtualenv的
python
的完整路径,例如:与之相反,比如说:
第一个将在当前环境中搜索,这将由virtualenv激活设置。第二个明确指向virtualenv的“python”。你知道吗
相关问题 更多 >
编程相关推荐