Use pip package inside Conda environment

笑着哭i 提交于 2021-01-28 07:08:40

问题


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?


回答1:


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:
e.g: 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 (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



来源:https://stackoverflow.com/questions/65064180/use-pip-package-inside-conda-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!