Installing conda packages¶
For more information about using the conda package manager in Anaconda Prompt (terminal on Linux or macOS), see the conda documentation.
You can also use the graphical interface Anaconda Navigator to install conda packages with just a few clicks.
Open an Anaconda Prompt (terminal on Linux or macOS) and follow these instructions.
Installing a conda package¶
Enter the command:
Installing specific versions of conda packages¶
Include the desired version number or its prefix after the package name:
To specify only a major version, run:
These commands install into the environment that is currently active. To install into a named environment, run:
If the package is specific to a Python version, conda uses the version installed in the current or named environment. For details on versions, dependencies and channels, see Conda FAQ and Conda Troubleshooting.
Installing packages on a non-networked (air-gapped) computer¶
To directly install a conda package from your local computer, run:
Conda installs packages into the anaconda/pkgs directory.
To install a .tar file containing many conda packages, run the following command:
If conda cannot find the file, try using an absolute path name instead of a relative path name.
Installing packages directly from the file does not resolve dependencies. If your installed package does not work, it may have missing dependencies that need to be resolved manually.
Managing packages
There are many options available for the commands described on this page. For details, see Command reference .
Searching for packages
Use the terminal or an Anaconda Prompt for the following steps.
To see if a specific package, such as SciPy, is available for installation:
To see if a specific package, such as SciPy, is available for installation from Anaconda.org:
To see if a specific package, such as iminuit, exists in a specific channel, such as http://conda.anaconda.org/mutirri, and is available for installation:
Installing packages
Use the terminal or an Anaconda Prompt for the following steps.
To install a specific package such as SciPy into an existing environment "myenv":
If you do not specify the environment name, which in this example is done by —name myenv , the package installs into the current environment:
To install a specific version of a package such as SciPy:
To install multiple packages at once, such as SciPy and cURL:
It is best to install all packages at once, so that all of the dependencies are installed at the same time.
To install multiple packages at once and specify the version of the package:
To install a package for a specific Python version:
If you want to use a specific Python version, it is best to use an environment with that version. For more information, see Troubleshooting .
Installing similar packages
Installing packages that have similar filenames and serve similar purposes may return unexpected results. The package last installed will likely determine the outcome, which may be undesirable. If the two packages have different names, or if you’re building variants of packages and need to line up other software in the stack, we recommend using Mutex metapackages .
Installing packages from Anaconda.org
Packages that are not available using conda install can be obtained from Anaconda.org, a package management service for both public and private package repositories. Anaconda.org is an Anaconda product, just like Anaconda and Miniconda.
To install a package from Anaconda.org:
To find the package named bottleneck, type bottleneck in the top-left box named Search Packages.
Find the package that you want and click it to go to the detail page.
The detail page displays the name of the channel. In this example it is the "pandas" channel.
Now that you know the channel name, use the conda install command to install the package. In your terminal window or an Anaconda Prompt, run:
This command tells conda to install the bottleneck package from the pandas channel on Anaconda.org.
To check that the package is installed, in your terminal window or an Anaconda Prompt, run:
A list of packages appears, including bottleneck.
For information on installing packages from multiple channels, see Managing channels .
Installing non-conda packages
If a package is not available from conda or Anaconda.org, you may be able to find and install the package via conda-forge or with another package manager like pip.
Pip packages do not have all the features of conda packages and we recommend first trying to install any package with conda. If the package is unavailable through conda, try finding and installing it with conda-forge.
If you still cannot install the package, you can try installing it with pip. The differences between pip and conda packages cause certain unavoidable limits in compatibility but conda works hard to be as compatible with pip as possible.
Both pip and conda are included in Anaconda and Miniconda, so you do not need to install them separately.
Conda environments replace virtualenv, so there is no need to activate a virtualenv before using pip.
It is possible to have pip installed outside a conda environment or inside a conda environment.
To gain the benefits of conda integration, be sure to install pip inside the currently active conda environment and then install packages with that instance of pip. The command conda list shows packages installed this way, with a label showing that they were installed with pip.
You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment .
If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.
To install a non-conda package:
Activate the environment where you want to put the program:
On Windows, in your Anaconda Prompt, run activate myenv .
On macOS and Linux, in your terminal window, run conda activate myenv .
To use pip to install a program such as See, in your terminal window or an Anaconda Prompt, run:
To verify the package was installed, in your terminal window or an Anaconda Prompt, run:
If the package is not shown, install pip as described in Using pip in an environment and try these commands again.
Installing commercial packages
Installing a commercial package such as IOPro is the same as installing any other package. In your terminal window or an Anaconda Prompt, run:
This command installs a free trial of one of Anaconda’s commercial packages called IOPro, which can speed up your Python processing. Except for academic use, this free trial expires after 30 days.
Viewing a list of installed packages
Use the terminal or an Anaconda Prompt for the following steps.
To list all of the packages in the active environment:
To list all of the packages in a deactivated environment:
Listing package dependencies
To find what packages are depending on a specific package in your environment, there is not one specific conda command. It requires a series of steps:
List the dependencies that a specific package requires to run: conda search package_name —info
Find your installation’s package cache directory: conda info
Find package dependencies. By default, Anaconda/Miniconda stores packages in
/opt/pkgs/ on macOS Catalina). Each package has an index.json file which lists the package’s dependencies. This file resides in
Now you can find what packages depend on a specific package. Use grep to search all index.json files as follows: grep package_name
The result will be the full package path and version of anything containing the <package_name>.
Example: grep numpy
Output from the above command:
Note this also returned “numpydoc” as it contains the string “numpy”. To get a more specific result set you can add < and >.
Updating packages
Use conda update command to check to see if a new update is available. If conda tells you an update is available, you can then choose whether or not to install it.
Use the terminal or an Anaconda Prompt for the following steps.
To update a specific package:
To update Python:
To update conda itself:
Conda updates to the highest version in its series, so Python 3.8 updates to the highest available in the 3.x series.
To update the Anaconda metapackage:
Regardless of what package you are updating, conda compares versions and then reports what is available to install. If no updates are available, conda reports "All requested packages are already installed."
If a newer version of your package is available and you wish to update it, type y to update:
Preventing packages from updating (pinning)
Pinning a package specification in an environment prevents packages listed in the pinned file from being updated.
In the environment’s conda-meta directory, add a file named pinned that includes a list of the packages that you do not want updated.
EXAMPLE: The file below forces NumPy to stay on the 1.7 series, which is any version that starts with 1.7. This also forces SciPy to stay at exactly version 0.14.2:
With this pinned file, conda update numpy keeps NumPy at 1.7.1, and conda install scipy=0.15.0 causes an error.
Use the —no-pin flag to override the update restriction on a package. In the terminal or an Anaconda Prompt, run:
Because the pinned specs are included with each conda install, subsequent conda update commands without —no-pin will revert NumPy back to the 1.7 series.
Adding default packages to new environments automatically
To automatically add default packages to each new environment that you create:
Open Anaconda Prompt or terminal and run: conda config —add create_default_packages PACKAGENAME1 PACKAGENAME2
Now, you can create new environments and the default packages will be installed in all of them.
You can also edit the .condarc file with a list of packages to create by default.
You can override this option at the command prompt with the —no-default-packages flag.
How to Install Python Package in Anaconda
The following command can be used to install a Python package in Anaconda:
In the next section, you’ll see the complete steps to install a package in Anaconda. You’ll also observe how to uninstall a package.
Steps to Install a Python Package in Anaconda
Step-1: Open the Anaconda Prompt
Locate your Anaconda Prompt, and then open it.
For example, if you’re using Windows, you can simply type ‘Anaconda Prompt’ in the Windows Search Bar (and then click on it).
You’ll then see the following screen with your user name:
Step-2: Install the Package
To install a Python package in Anaconda, simply use the command that was introduced at the beginning of this guide:
For example, let’s suppose that you’d like to install the pyautogui package, which can be used to control the mouse and keyboard. In that case, type the following command in the Anaconda Prompt:
After you typed the above command, press ENTER to proceed with the installation:
The Python package would now get installed.
Step-3: Verify that the package was installed
Once the package got successfully installed, you’ll see the following status in the Anaconda Prompt:
Next, you’ll see how to uninstall an existing package.
Steps to Uninstall a Python package in Anaconda
Step-1: Open the Anaconda Prompt
First open the Anaconda Prompt. As before, you’ll see the following screen with your user name:
Step-2: Uninstall the Package
You can then uninstall a Python package using this template:
Once you are done typing the command with the package name that you’d like to uninstall, press ENTER to execute the command.
To proceed with the removal of the package, type ‘y‘ and then press ENTER:
You may also want to check the following guide for the steps to upgrade PIP in Anaconda.
Using Pip to install packages to Anaconda Environment
I am trying to install packages from pip to a fresh environment (virtual) created using anaconda. In the Anaconda docs it says this is perfectly fine. It is done the same way as for virtualenv.
Activate the environment where you want to put the program, then pip install a program.
I created an empty environment in Ananconda like this:
I then can see in the terminal that I am working in my env (shrink_venv) . Problem is coming up, when I try to install a package using pip :
So I can see it thinks the requirement is satisfied from the system-wide package. So it seems the environment is not working correctly, definitely not like it said in the docs. Am I doing something wrong here?
Just a note, I know you can use conda install for the packages, but I have had an issue with Pillow from anaconda, so I wanted to get it from pip , and since the docs say that is fine.
Output of which -a pip :
** UPDATE ** I see this is pretty common issue. What I have found is that the conda env doesn’t play well with the PYTHONPATH. The system seems to always look in the PYTHONPATH locations even when you’re using a conda environment. Now, I always run unset PYTHONPATH when using a conda environment, and it works much better. I’m on a mac.
18 Answers 18
For others who run into this situation, I found this to be the most straightforward solution:
Run conda create -n venv_name and conda activate venv_name , where venv_name is the name of your virtual environment.
Run conda install pip . This will install pip to your venv directory.
Find your anaconda directory, and find the actual venv folder. It should be somewhere like /anaconda/envs/venv_name/ .
Install new packages by doing /anaconda/envs/venv_name/bin/pip install package_name .
This should now successfully install packages using that virtual environment’s pip!
All you have to do is open Anaconda Prompt and type
It will automatically install to the anaconda environment without having to use
Since some of the conda packages may lack support overtime it is required to install using pip and this is one way to do it
If you have pip installed in anaconda you can run the following in jupyter notebook or in your python shell that is linked to anaconda
Check your version of pip with pip.__version__ . If it is version 10.x.x or above, then install your python package with this line of code
In your jupyter notebook, you can install python packages through pip in a cell this way;
or you could use your python version associated with anaconda
![]()
I solved this problem the following way:
If you have a non-conda pip as your default pip but conda python is your default python (as below)
Then instead of just calling pip install <package> , you can use the module flag -m with python so that it uses the anaconda python for the installation
This installs the package to the anaconda library directory rather than to the library directory associated with (the non-anaconda) pip
EDIT: The reason this works is as follows: the command pip references a specific pip file/shortcut ( which -a pip tells you which one). Similarly, the command python references a specific python file ( which -a python tells you which one). For one reason or another these two commands can become unsynchronized, so that your ‘default’ pip is in a different folder than your default python, and therefore is associated with a different version of python.
In contrast, the python -m pip construction does not use the shortcut that the pip command points to. Instead, it asks python to find its version of pip and use that version to install a package.