Anaconda 安装找不到包

Anaconda installation not finding packages

通过我正在尝试做的事情和正在发生的事情可以最好地展示这一点。

在我的 python 文件中,我想导入 seaborn。

可以通过conda安装。

(me_dev)[me@ip-***]$ conda install seaborn
Fetching package metadata: ....
Solving package specifications: ............................
# All requested packages already installed.
# packages in environment at /home/me/miniconda/envs/me_dev:
#
seaborn                   0.7.0                    py27_0

(me_dev)[me@ip-***** ****]$ which python
~/miniconda/bin/python

(me_dev)[me@ip-****]$ which ipython
~/miniconda/bin/ipython

现在,如果我开始 iPython 并导入 seaborn:

In [1]: import seaborn
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-085c0287ecb5> in <module>()
----> 1 import seaborn

ImportError: No module named seaborn

此外,pip 也不起作用。它不是从 pip 读取包。

(me_dev)[me@ip-*****]$ pip install jellyfish
Requirement already satisfied (use --upgrade to upgrade): jellyfish in /home/me/miniconda/lib/python2.7/site-packages

还:

from jellyfish import jaro_winkler ImportError: No module named jellyfish

编辑: sys.path 在 iPython

中看起来是这样
['',
 '/home/me/miniconda/bin',
 '/home/me/miniconda/lib/python27.zip',
 '/home/me/miniconda/lib/python2.7',
 '/home/me/miniconda/lib/python2.7/plat-linux2',
 '/home/me/miniconda/lib/python2.7/lib-tk',
 '/home/me/miniconda/lib/python2.7/lib-old',
 '/home/me/miniconda/lib/python2.7/lib-dynload',
 '/home/me/miniconda/lib/python2.7/site-packages/setuptools-19.6.2-py2.7.egg',
 '/home/me/miniconda/lib/python2.7/site-packages',
 '/home/me/miniconda/lib/python2.7/site-packages/cryptography-1.0.2-py2.7-linux-x86_64.egg',
 '/home/me/miniconda/lib/python2.7/site-packages/IPython/extensions',
 '/home/me/.ipython']

这是我的 .bashsrc

(me_dev)[me@ip-**** ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# added by Miniconda 3.16.0 installer
export PATH="/home/me/miniconda/bin:$PATH"

# User specific aliases and functions
source activate me_dev

# added by Miniconda2 3.19.0 installer
export PATH="/home/me/miniconda/bin:$PATH"

我认为 which python(和 which ipython)应该指向 ~/miniconda/envs/me_dev/bin/,而不是 ~/miniconda/bin/ 目录。当您使用这些二进制文件启动 python 会话时,它们看不到您的 seaborn 库,它可能只安装在环境站点包中。

我不确定您最终是如何进入这种状态的,但我建议您尝试创建一个新环境,看看您是否最终指向了正确的二进制文件。

您的 .bashrc 组织是问题所在。您正在激活您的虚拟环境,但随后在您的 $PATH 中赋予主 miniconda bin 目录优先权,这具有部分停用虚拟环境的效果。