pip / virtualenv / django 安装问题
我在一个新的 virtualenv 上,并尝试在其上安装 django。
当我输入 which django-admin.py
时,我得到 /usr/local/bin/django-admin.py
这是不正确的,它应该安装在.virtualenvs 文件夹。
如果我这样做,pip install django
我会得到:
Requirement already satisfied (use --upgrade to upgrade): django in /Library/Python/2.6/site-packages
如果我这样做,pip uninstall django
我会得到:
Not uninstalling Django at /Library/Python/2.6/site-packages, outside environment /Users/username/.virtualenvs/envname/bin/..
How do I get pip to install and use django inside the virtualenv?不知道如何解决这个问题。
I'm on a new virtualenv, and trying to install django on it.
When I type, which django-admin.py
I get back /usr/local/bin/django-admin.py
which is not correct, it should be installing inside the .virtualenvs folder.
If I do, pip install django
I get back:
Requirement already satisfied (use --upgrade to upgrade): django in /Library/Python/2.6/site-packages
If I do, pip uninstall django
I get back:
Not uninstalling Django at /Library/Python/2.6/site-packages, outside environment /Users/username/.virtualenvs/envname/bin/..
How do I get pip to install and use django inside the virtualenv? No idea how to troubleshoot this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您应该使用
--no-site-packages
设置 virtualenv:然后您应该确保已激活它:
或者,使用 virtualenv helper:
然后使用以下命令安装 Django:
First, you should be setting up the virtualenv with
--no-site-packages
:Then you should make sure that you've activated it:
Or, with virtualenv helper:
Then install Django with:
就像 David 指出的那样,您应该告诉 virtualenv 不要使用虚拟环境之外的包(使用 --no-site-packages 标志)。这就是为什么“which django-admin.py”返回“/usr/local/bin/django-admin.py”
Like David pointed out, you should tell virtualenv not to use packages outside your virtual environment (using the --no-site-packages flag). That's why "which django-admin.py" returns "/usr/local/bin/django-admin.py"