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
How to install the library
- 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.
For beginners! Anaconda Navigator
Anaconda comes with a standard application called Anaconda Navigator installed.
Now, let’s open it and install the library!
- Launch Anaconda Navigator
- Go to Environments
- Search for the library and click Apply
- 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
(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.
- Launch Anaconda Prompt
- Install with conda install and enter y
- 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”
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
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.
- Launch Command Prompt
- Check Conda version
- Install by conda install
- 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
(3) Install by conda install
Installed by conda install “library”
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
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
- Can you install with conda install “library”?
- Does it exist on Anaconda.org? (conda-forge)
- 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 listでconda環境の中にpipを使ってdjango-cacheopsをインストールできたことがわかります
conda list shows that I was able to install django-cacheops using pip in the conda environment
References
Anaconda.org
PyPI
Comments