pip / virtualenv / django installation issue

2019-01-23 16:01发布

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.

2条回答
你好瞎i
2楼-- · 2019-01-23 16:14

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"

查看更多
看我几分像从前
3楼-- · 2019-01-23 16:29

First, you should be setting up the virtualenv with --no-site-packages:

virtualenv --no-site-packages …/my-env/

Then you should make sure that you've activated it:

. …/my-env/bin/activate

Or, with virtualenv helper:

workon my-env

Then install Django with:

pip install django
查看更多
登录 后发表回答