As I understand it, if I use pip install ___, that package will go to my global version of python. If I change directory to the within my Conda environment then that package will be isolated within the environment. Is this correct?
I have searched to try and find where to put the pip packages (within my Conda environment). It used to be that you would install the pip packages in /Anaconda3/envs/venv_name/bin/
. It appears the bin
folder is now located within the Library folder, like this: /Anaconda3/envs/venv_name/Library/bin
. Is the bin
folder still the recommended place to put the packages installed by pip?
In other words should I be placing the pip installed packages here: /Anaconda3/envs/venv_name/Library/bin
?
Fortunately, one doesn't have to manually designate where to install the packages. Instead, if one uses the pip
associated with the environment, it will install them to the site-packages
directory of env's python
.
> conda activate venv_name
# check that you are using the right pip
> which pip
/Anaconda3/envs/venv_name/bin/pip # should be something like this
> pip install <package name>
This will install packages into /Anaconda3/envs/venv_name/lib/python3.7/site-packages/
, or whatever Python version you have install for the env.
Be aware that (as @WilliamDIrons pointed out), it is usually preferable to use conda install -n venv_name <package name>
instead of pip
. The common practice is to only use pip
in a Conda env when the package is not available through a Conda repository. It is strongly recommended to read and follow the best practices found in the " Using pip in an environment " documentation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.