I have a project called ABC
, I have a conda env just for it in the fold ~/anaconda/envs/ABC
, I believe it is a venv, and I want to use some specific packages from the global site packages.
For normal Python installation it can be done be removing the no-global-site-package.txt from the venv folder, or by setting the venv to use global-site-packages, but I didn't find any equivalent approach to do this in Anaconda. The online documentation does not have answer either.
How to do this for Anaconda?
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment. You can also share an environment file.
The answer is the site-packages in the sys. path list.
If you created the new environment using something like conda create --name dell_proj , it will not inherit packages from the base environment. You would have to install the packages you want using conda install .
you cannot do this explicitly in conda, where the principle is that envs are entirely separate.
but the current default behavior of conda
is to allow all global user site-packages to be seen from within environments, as mentioned in this question. so, the default behavior will allow you to do as you wish, but there is no way to allow only "some specific" global packages as requested.
this behavior has caused one or two issues. to avoid it, export PYTHONNOUSERSITE=1
before source activate <your env>
. note that the devs are planning to change the default behavior to set PYTHONNOUSERSITE=1
in 4.4.0 (per the second issue linked).
In case anyone is coming back to this now, for conda 4.7.12, entering export PYTHONNOUSERSITE=True
before the conda activate
call successfully isolated the conda environment from global/user site packages for me.
On the other hand, entering export PYTHONNOUSERSITE=0
allows the conda environment to be reintroduced to the global/user site packages.
Note: This is instead of the previously suggested export PYTHONNOUSERSITE=1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With