简体   繁体   中英

Anaconda installation not finding packages

This one is best shown through what I'm trying to do and what is going on.

In my python file, I want to import seaborn.

It's available to install via 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

Now if I start iPython and import 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

Also, pip is not working either. It's not reading packages from 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

Yet:

from jellyfish import jaro_winkler ImportError: No module named jellyfish

Edit: sys.path looks like so in 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']

Here's my .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"

I think which python (and which ipython ) should be pointing at ~/miniconda/envs/me_dev/bin/ , not at ~/miniconda/bin/ directory. When you start an python session with those binaries, they can't see your seaborn library, which is probably only installed in the environment site packages.

I'm not sure exactly how you ended up in this state, but I would recommend trying to make a new environment and see if you end up pointed at the correct binaries.

The organization your .bashrc is the problem. You're activating your virtual environment, but then giving the main miniconda bin directory precedence in your $PATH , which has the effect of partially inactivating the virtual environment.

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