Run pip to Install a Package to Anaconda Environment¶
Context¶
User created a conda environment named myenv and tried to install a package named <some_special_package>. The package is not available in conda, and user has to install the package using pip install <some_special_package>. However, the package is then installed in the base environment in conda instead of the myenv environment.
Problem¶
How to install the package in myenv environment using pip?
Solution¶
Do the followings:
-
Install
pipundermyenvenvironment if it is not already availablecondat install -n myenv pip -
Find the location of the
pipin themyenvenvironment.- If the root of Anaconda is
/path/to/anaconda, thepipformyenvenvironment should be found at/path/to/anaconda/envs/myenv/Scripts/pip
- If the root of Anaconda is
-
Use the
pipin themyenvenvironment to install the package/path/to/anaconda/envs/myenv/Scripts/pip install <some_special_package>