How to reuse global site packages in conda env

I have a project called ABC , I have conda env only for it in fold ~/anaconda/envs/ABC , I believe that it is venv, and I want to use some specific packages from global site packages.

For a normal Python installation, this can be done by deleting the no-global-site-package.txt file from the venv folder or installing venv to use global-site packages, but I did not find an equivalent approach to do this in Anaconda. There is no answer in the online documentation either.

How to do it for Anaconda?

+6
source share
2 answers

you cannot do this explicitly in conda, where the principle is that envs are completely separate.

but the current conda default conda is to allow global packages of user sites all to see from within the environment, as mentioned in this question . therefore, the default behavior will allow you to do what you need, but there is no way to allow only “some specific” global packages.

this behavior raised one or two questions. to avoid this, export PYTHONNOUSERSITE=1 to source activate <your env> . note that the developers plan to change the default behavior to set PYTHONNOUSERSITE=1 to 4.4.0 (from the second linked link).

+1
source

You can use the PYTHONPATH environment variable. for instance

 export PYTHONPATH="/Users/me/anaconda/lib/python2.7/site-packages:$PYTHONPATH" 

gives each environment access to all the libraries in the anaconda distribution. However, disagreement over the goals of the environment. And if you want to access the library that you installed using home-brew, add

 export PYTHONPATH=/usr/local/Cellar/another_package/lib/python2.7/site-packages:$PYTHONPATH 
0
source

All Articles