开发者

virtualenv --no-site-packages is not working for me

virtualenv --no-site-packages v1

开发者_Go百科cd v1\Scripts

activate.bat

python -c "import django" # - no problem here

Why does it see the Django package??? It should give me an import error, right?


Just unset PYTHONPATH environment variable. The idea of virtualenv is that you can create your own environment (fully isolated or extending the default one) so you don't have to mess with that.

As someone noticed there's already been a similar question on SO. Read it if you need a better explanation.


It should not raise any ImportError as long as there is a django package in the sys.path.

If you're wondering where django comes from, run:

python -c "import django; print django.__file__"

Then check Python's Module Search Path.

UPDATE: As pointed out in the comments: Take into account that the --no-site-packages option in virtualenv only removes the standard site-packages directory from sys.path. The other paths just remain the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜