Can I use PIP in Conda


38.4 The package manager conda

If you use the Python distribution Anaconda, the package manager is also available, with which you can conveniently install Python packages. One advantage over and other package managers is that he can install and manage other programs in addition to Python packages. It is also ensured that the packages and programs installed by are available in matching versions.

The package manager offers extensive functionality [179] (For example, mechanisms are offered to install different versions of Python and packages in parallel and to easily switch between the installed versions. Further information can be found in the documentation at https: // conda.io/docs/using/.), which goes far beyond our requirements in the context of this book. It is available in a version for the command line or in a graphical variant. We will limit ourselves to a few basic functions in the version for the command line.

To use it, open a command line via the start menu entry Anaconda Prompt on Windows and a shell on Linux or macOS.

[»] Note for Linux or macOS

If you did not set the Anaconda Python interpreter as the standard Python during installation, as described in Section 2.2, you must first execute the following command:

$ export PATH = / home / your_user / anaconda3 / bin: $ PATH

Where / home / your_user / anaconda3 is the path where you installed Anaconda.

You can now execute from the command line or shell. For example, with the following call you will get the currently installed version of:

$ conda --version
conda 4.3.14

A typical call to conda has the following structure:

As with, there are, among other things, commands for installing and uninstalling Python packages. Table 38.3 shows a selection of the available commands.

command importance
Displays information about the installation of.
Returns a description of the use of in English.
Searches for packages by name.
Displays all installed packages.
Install packages.
Uninstalls packages.
Updated packages.

Table 38.3 Some of the commands from

The package discussed in Chapter 40 will serve as an example.

First we use the search function of to look for the package. We do not have to specify the exact name of the package, part of the name is sufficient:

$ conda search jan
Fetching package metadata .........
django 1.6.5 py26_0 defaults
[…]
1.10.5 py27_0 defaults
1.10.5 py34_0 defaults
1.10.5 py35_0 defaults
1.10.5 py36_0 defaults
r-janeaustenr 0.1.4 r3.3.2_0 defaults

The output informs us that the package and has found our request. In addition, the available combinations of version of the package and version of the Python interpreter are displayed for each package found.

Use the following command to install the latest version for the currently selected Python interpreter:

$ conda install django
Fetching package metadata .........
Solving package specifications:.
Package plan for installation in environment / home / your_user / anaconda3:
The following NEW packages will be INSTALLED:
django: 1.10.5-py36_0
Proceed ([y] / n)?

To confirm the installation, acknowledge the last question with (¢). If you then display the list of installed packages, is included there.

$ conda list
[…]
django 1.10.5 py36_0
[…]

To remove the package again, you can use the command:

$ conda remove django
Fetching package metadata .........
Solving package specifications:.
Package plan for package removal in environment / home / your_user / anaconda3:
The following packages will be REMOVED:
django: 1.10.5-py36_0
Proceed ([y] / n)?

In some use cases, you need a specific version of a package. Let's say we need version 1.10.4 of the. Using, we can install it by adding an equal sign after the package name, followed by the desired version number:

$ conda install django = 1.10.4
Fetching package metadata .........
Solving package specifications:.
Package plan for installation in environment / home / your_user / anaconda3:
The following NEW packages will be INSTALLED:
django: 1.10.4-py36_0
Proceed ([y] / n)?

Of course, you can only install the versions that are available in the database in this way.

["] Note

In practice, you should always use the latest available version of software unless there is a valid reason for using an old version.

How did you like the Openbook? We always look forward to your feedback. Please send us your feedback as an e-mail to [email protected]