[Anaconda] How to use pip to install packages under conda

problem background

condaThe required package could not be downloaded.

Many packages are only available inpipThere are: PYPI has 150,000 packages available, while more than 1,500 packages are available in the Anaconda repository (installed with the conda command), and several thousand others on the Anaconda cloud (installed with the conda-forge or bioconda commands).

Operation guide

Enter the Python environment where the package needs to be installed:

conda activate [your_env]
# eg: conda activate tensorflow_36
  • 1
  • 2

run:

pip install [package]
# eg: pip install tensorflow
  • 1
  • 2

Precautions

1). If a package is installed with pip in an environment env_a, is it available in env_b?

​ Not available.

2). If a package is installed with pip in the base, is it available in other environments?

​ Available, but not recommended.
Packages installed in the base environment are shared by other conda environments. At this time, there may be a version conflict problem: different environments may have different version requirements for the same package.

3). How to judge whether a package in conda is installed by conda or pip?

conda list, the package installed with pip shows the build project as pypi.

4). When a package can be installed with conda or pip, which one to use?

​ conda.
pip and conda differ in how they satisfy dependencies in the environment when installing packages. pip installs dependencies in a recursive serial loop, does not ensure that all packages' dependencies are satisfied at the same time, if packages installed earlier in order have incompatible versions of dependencies relative to packages installed later in order , it may cause the environment to be corrupted in subtle ways; conda uses a SAT (satisfiability) solver to verify that all requirements of all packages installed in the environment are met, and as long as the package metadata about dependencies is correct, conda will press Expected to produce a usable environment.

Version

conda 4.9.2 # useconda --versionCheck.

pip 20+ # usepip --versionCheck. Different Python environments may have different pip versions installed.

refer to

Tags: [Anaconda] How to use pip to install packages under conda

Python python deep learning anaconda

Related: [Anaconda] How to use pip to install packages under conda