Anaconda | conda? pip? How to install the library

Anaconda comes with the necessary libraries for data analysis installed from the beginning.

If you want to install new libraries, use conda, but not all libraries can be installed.

This article explains in detail the basic conda install, how to specify the version, how to resolve PackagesNotFoundError errors using Anaconda.org, and how to install using pip in the conda environment.

Please refer to the following article for instructions on installing Anaconda on Windows

Table of Contents

How to install the library

How to install a new library with Anaconda
  • Using Anaconda Navigator’s Environments
  • conda install ”library”
  • conda install -c conda-forge ”library”
  • pip install ”library”

There are two main installation methods: (1) GUI method using Anaconda Navigator, and (2) CUI method by typing commands in a shell.

I recommend the CUI format that uses the (2) shell because it can handle anything.

While the GUI format of ① is easy to understand, it is not universal and is slow.

For beginners! Anaconda Navigator

Anaconda comes with a standard application called Anaconda Navigator installed.

Now, let’s open it and install the library!

Installation Procedure
  1. Launch Anaconda Navigator
  2. Go to Environments
  3. Search for the library and click Apply
  4. Check the installed the library

(1) Launch Anaconda Navigator

Press the Windows symbol on the keyboard or click the Windows symbol on the taskbar

Search for anaconda and launch Anaconda Navigator (takes about 2 minutes)

(2) Go to Environments

Click on Environments from the menu on the left to enter your environment

It is also possible to create a virtual environment with Create instead of base (root)

(3) Search for the library and click Apply

Search for the library in Search Pagckages in the upper right corner and click Apply in the lower right corner.

Then you will be asked again which library you want to install, so click Apply again.

(4) Check the installed the library

Select Installed from the drop-down menu above the library’s Name, and search for the library using Search Pagckages in the upper right corner.

If it appears, it is installed without any problem.

Author’s Recommendation! Anaconda Prompt

Anaconda comes with a shell called Anaconda Prompt installed by default.

Installation Procedure
  1. Launch Anaconda Prompt
  2. Install with conda install and enter y
  3. Check installed libraries

(1) Launch Anaconda Prompt

Press the Windows symbol on the keyboard or click the Windows symbol on the taskbar

Search for anaconda and launch AnacondaPrompt

(2) Install with conda install and enter y

Installed by conda install “library”

If “library name”==”version”, the version is specified

conda install django==4.1

Enter “y” or “n” in Proceed as shown below.

Proceed ([y]/n)?

(3) Check installed libraries

You can check the installed libraries in the conda list

Libraries are arranged in ABC order

conda list

# dill                      0.3.4              pyhd3eb1b0_0
# distributed               2022.7.0         py39haa95532_0
# django                    4.1              py39haa95532_0
# docutils                  0.18.1           py39haa95532_3
# entrypoints               0.4              py39haa95532_0

Advanced users! Command Prompt

In Windows, a shell called Command Prompt is installed by default.

Installation Procedure
  1. Launch Command Prompt
  2. Check Conda version
  3. Install by conda install
  4. Check installed the library

(1) Launch Command Prompt

Press the Windows symbol on the keyboard or click the Windows symbol on the taskbar

Search for anaconda and launch the command prompt

(2) Check Conda version

Try typing conda -V to see if it returns Conda version information

conda -V

# conda 23.1.0

If it does not work, please refer to the following article and reinstall

(3) Install by conda install

Installed by conda install “library”

If “library name”==”version”, the version is specified

conda install django==4.1

Enter “y” or “n” in Proceed as shown below.

Proceed ([y]/n)?

(4) Check installed the library

You can check the installed libraries in the conda list

Libraries are arranged in ABC order

conda list

# dill                      0.3.4              pyhd3eb1b0_0
# distributed               2022.7.0         py39haa95532_0
# django                    4.1              py39haa95532_0
# docutils                  0.18.1           py39haa95532_3
# entrypoints               0.4              py39haa95532_0

Cannot install with conda install

It is often the case that conda install fails to install with “library”.

In that case, let’s check the following steps

Installation Confirmation Procedure
  1. Can you install with conda install “library”?
  2. Does it exist on Anaconda.org? (conda-forge)
  3. Does it exist on PyPI? (pip)

Resolving PackagesNotFoundError with conda-forge

I’m trying to add django-import-export, which is useful for adding import/export functionality for CSV files etc. in django

I get a PackagesNotFoundError error when doing so

conda install django-import-export

# PackagesNotFoundError: The following packages are not available from current channels:

#  - django-import-export

# Current channels:

#   - https://repo.anaconda.com/pkgs/main/win-64
#   - https://repo.anaconda.com/pkgs/main/noarch
#   - https://repo.anaconda.com/pkgs/r/win-64
#   - https://repo.anaconda.com/pkgs/r/noarch
#   - https://repo.anaconda.com/pkgs/msys2/win-64
#   - https://repo.anaconda.com/pkgs/msys2/noarch

# To search for alternate channels that may provide the conda package you're
# looking for, navigate to

#     https://anaconda.org

# and use the search bar at the top of the page.

In this case, go to Anaconda.org and search for django-import-export

In the search results you will see the following

  • Is there a conda-forge / “library”?
  • Is there a sufficient number of downloads?
  • Is there a platform with the same environment?

Click on conda-forge/django-import-export

The library page contains code for conda install

Copy and paste conda install -c conda-forge “library” and run it with Anaconda Prompt.

conda install -c conda-forge django-import-export

You can check the installed libraries in the conda list

Installed in conda environment via pip

I’ll add django-cacheops to cache DB accesses via ORM in django

conda install “library” does not add it, so search for django-cacheops on Anaconda.org

Cannot install due to lack of conda-forge

If you search for PyPI, it exists, so you can pip install it directly into the conda environment.

pip install django-cacheops

conda listconda環境の中にpipを使ってdjango-cacheopsをインストールできたことがわかります

conda list shows that I was able to install django-cacheops using pip in the conda environment

References

Anaconda.org

PyPI

I hope you will share it with me!
  • URLをコピーしました!

Comments

コメントする

Table of Contents