Created
August 25, 2016 14:06
-
-
Save chhantyal/ffd2b2d4158925c6f335ce1cc2b190f3 to your computer and use it in GitHub Desktop.
It gives error when symlinked python command (from virtualenv) is used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ virtualenv venv | |
# Symlink virtualenv bin/ to bin on current directory | |
$ ln -s venv/bin/ bin | |
# Run python from symlinked | |
$ bin/python | |
# Inside Python shell | |
$ >>> import datetime | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ImportError: No module named datetime | |
# But this works with Python installed via brew | |
$ ln -s /usr/local/bin/ bin | |
$ bin/python | |
>>> import datetime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, it's because of path. Python updates sys.path according to current directory of interpreter, and doesn't work with symlink https://groups.google.com/forum/#!topic/python-virtualenv/rjJ4aYXrTDs