无法在虚拟环境中导入使用conda安装的模块

时间:2017-11-14 08:59:48

标签: linux python-3.x import module conda

anaconda3安装在linux上。

使用conda安装了几个模块。它们是可见的:

(cytogen) jeanpat@10TS-Notebook:~$ conda list
# packages in environment at /home/jeanpat/anaconda3/envs/cytogen:
#
boost                     1.64.0                   py36_4    conda-forge
boost-cpp                 1.64.0                        1    conda-forge
bzip2                     1.0.6                         1    conda-forge
ca-certificates           2017.08.26           h1d4fec5_0  

...

graph-tool                2.25             py36hbffa022_0    ostrokach-forge
hdf5                      1.8.17                        2  

mahotas                   1.4.4                    py36_0    conda-forge
mkl                       2018.0.0             hb491cac_4  
mpfr                      3.1.5                         0    conda-forge
ncurses                   6.0                  h9df7e31_2  
numpy                     1.12.1           py36he24570b_1  
opencv                    3.1.0               np112py36_1  
opencv3                   3.1.0                    py36_0    menpo
openssl                   1.0.2m               h8cfc7e7_0  
pandas                    0.21.0                   py36_0    conda-forge
pillow                    3.4.2                    py36_0  
pip                       9.0.1            py36h6c6f9ce_4  

...

pytorch                   0.2.0           py36hf0d2509_4cu75    soumith
pytz                      2017.3                     py_2    conda-forge
readline                  7.0                  ha6073c6_4  
scipy                     1.0.0            py36hbf646e7_0  
setuptools                36.5.0           py36he42e2e1_0  
six                       1.11.0                   py36_1    conda-forge
sparsehash                2.0.3                         0    conda-forge
sqlite                    3.20.1               hb898158_2  
tk                        8.6.7                hc745277_3  
torchvision               0.1.9            py36h7584368_1    soumith
wheel                     0.29.0           py36he7f4e38_1  
xz                        5.2.3                h55aa19d_2  
zlib                      1.2.11               ha838bed_2 

启动ipython后,某些模块无法导入(cv2,mahotas ......):

~$ ipython
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import mahotas
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-adadab8066d2> in <module>()
----> 1 import mahotas

ModuleNotFoundError: No module named 'mahotas'

In [2]: import cv2
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-72fbbcfe2587> in <module>()
----> 1 import cv2

ModuleNotFoundError: No module named 'cv2'

我想这是一个路径问题,例如导入numpy作品:

In [3]: import numpy

In [4]: numpy.__version__
Out[4]: '1.13.3'

但该版本与virtualenv的numpy版本不匹配。

0 个答案:

没有答案