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.
精彩评论