简体   繁体   中英

Use pip package inside Conda environment

I am confused about how the packages installed through pip and conda work together. What I do know:

  • pip and conda install different package format. What are the implications here except that pip can not install the conda package format? (which is fine for the purpose of this question since you can always use the appropriate command to install a package; I am interested in the part that follows)

Say, package A is installed via pip ; package B installed via conda in an isolated conda environment custom_env . Now, I create a python script, which needs to use both package A and package B ; I launch it inside the custom_env .

Will the python script have access to package A ?

Question: Will the python script have access to package A?
Answer: : It seems no.

..and it makes sense.
I expected conda to guarantee an isolated environment.
But I needed to test this assumption.

How I tested it:
1 - pick a package:
eg: scipy

2 - deactivate conda:
conda deactivate

3 - check if scipy is installed in pip:
pip list | grep scipy
Output:
scipy 0.13.0b1

4 - activate conda environment:
conda activate

5 - check if conda see a scipy package:
conda list | grep scipy
Output:
(empty)

( Double Check )
6 - you might have a pip as part of the conda environment,
let's check it too with:
pip list | grep scipy pip list | grep scipy (with conda environment activated).
Output:

( Triple Check )
7 - I also tried to:
A - import scipy without conda environment ( with pip ) -> success
B - import scipy inside conda environment -> error

scipy inside vs conda 外部

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM