python - In a virtual env the sys.path is wrong when I import a package from a file -
the sys.path change if import package file.
in pyenv :
$(env) python >>> import sys >>> print(sys.path) ['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/var/www/lib/python3.4/site-packages']
in fileimport.py (inside virtual env) :
# fileimport.py import sys print(sys.path)
the command :
$(env) python fileimport.py
gives me same result!
but when try import fileimport package anotherfile.py :
#!/usr/bin/env python # anotherfile.py import fileimport
the sys.path result change :
$(env) python anotherfile.py ['/var/www', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
i install pyenv :
$ sudo apt-get install python3.4-venv python3-dev $ pyvenv-3.4 env
i don't understand why import file uses sys.path system , not virtual env.
thank in advance help.
i solved problem changing shebang.
in virtual env can use :
$(env) /usr/bin/env python
but in file shebang must point exact location of virtual python. in case :
#!/var/www/bin/python
i hope help.
Comments
Post a Comment