python – Anaconda安装没有找到包

通过我正在尝试做的和正在发生的事情,最好地展示了这一点.

在我的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

编辑:
在iPython中,sys.path看起来像这样

['',
 '/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"

解决方法:

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

我不确定你是如何在这种状态下结束的,但我建议你尝试建立一个新的环境,看看你是否最终指向了正确的二进制文件.

组织你的.bashrc就是问题所在.您正在激活虚拟环境,但随后在$PATH中提供主miniconda bin目录优先级,这会部分地停用虚拟环境.

上一篇:python – 使用seaborn.kdeplot添加框架并删除背景颜色和网格


下一篇:python – 大量数据的散点图