为什么 virtualenv 不包含所有系统路径?
我创建了一个 virtualenv,虽然它有很多系统路径,但没有其他路径。具体来说,似乎不包括 pyshared 和 dist-packages。因此,我的系统范围内的 MySQLdb 和 psycopg2 不可用。有什么想法吗?
I created a virtualenv, and while it has many system paths, it doesn't have others. Specifically, pyshared and dist-packages don't seem to be included. As a result, my system-wide MySQLdb and psycopg2 aren't available. Any ideas why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎与 Ubuntu 与 python 的混乱有关虚拟环境
Seems to be related to Ubuntu's messing with python and virtualenv
我知道的唯一可能的方法是,如果您使用参数 --no-site-packages:
from 这里:
所以这里有一个例子来了解更多:
首先我将正常创建一个 virtualenv (没有 --no-site-package ),你会看到
我总是可以访问安装在我的系统站点包(或 dist-packages)中的 django:
但现在我将使用 --no-site-package 创建虚拟环境:
现在您看到 virtaulenv能够从我的机器中的系统 dist-packages (ubuntu) 访问 django。
希望这会有所帮助:)
The only possible way that i'm aware of, is if you have created your virtualenv with the argument --no-site-packages:
from Here:
so Here is an example to understand more:
First i will create a virtualenv normally (without --no-site-package) and you will see that
i can always access django that is installed in my system site-packages (or dist-packages):
But now i will create the virtual env using --no-site-package:
now you see that virtaulenv was able to access django from system dist-packages (ubuntu) in my machine.
Hope this will help :)