python - Can virtualenvs be made to fall back to user packages instead of system packages? -
I use Python for autocomplete in amax, but this is not my code dependency, so I Do not want to insert my requirements.txt
. (Other developers can not use a JDI editor plugin, and when I deploy to Heroku, it definitely does not need it.)
But Jedi is available to work from my VirtualNV That means if I
import jedi
this does not work.
Is there any good way to set up a JDI user-universally that it is available in all my Virtual Connections?
I think what do i want
- in jdi
~ / .local / lib / python2.7 / site-packages / Then with
, then - to create my virtualenv, but instead of the user package system package.
My current workaround is for pip installation jedi
in each of my virtual envisions, when I add new dependencies I pip install foo
, pip freeze> Requirements.txt
, then manually delete jedi
and some other things before the file. Obviously, this is time consuming and error prone.
Is anyone's better solution?
when virtuenv
active
s, this many Changes env variables, such as PATH
, PYTHONHOME
, to indicate the desired python binary, library, etc. PS1
and so on , You can change the script to replace PYTHONPATH
to use your user site package, i.e. ~ / .local / lib / python2.7 / site-packages
, And possibly your system site-package with this setting, the PIP book Searches in virtual env to the rhythm, and then the user / system failure for the site-packages. Note that the usual active script does not change PYTHONPATH
at all.
That is, add the following lines to your virtual_env / bin / activate
.
#include function in active # script if [-n "$ _OLD_VIRTUAL_PYTHONPATH"]; Then PYTHONPATH = "$ _ OLD_VIRTUAL_PYTHONPATH" export PYTHONPATH unknowingly _OLD_VIRTUAL_PYTHONPATH Fine # if in the active section [-n "$ PYTHONPATH"]; So _OLD_VIRTUAL_PYTHONPATH = "$ PYTHONPATH" PYTHONPATH = $ HOME / .local / lib / python2.7 / site-package: /usr/lib/python2.7/site-packages fi
Comments
Post a Comment