Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anaconda not finding my packages installed with `pip`

Tags:

I'm new to Anaconda version of Python, and already I'm running into unpleasant problems.

I installed Anaconda per the instructions here, and it worked like charm, with all the included packages imported properly when demanded. Then I went on to install some extra packages which Anaconda did not included in the first place with pip:

$ sudo pip install BeautifulSoup mrjob pattern 

The installations seems to be perfect, but when I try to import them in ipython, things get frustrating:

Python 2.7.6 |Anaconda 1.8.0 (64-bit)| (default, Nov 11 2013, 10:47:18)  Type "copyright", "credits" or "license" for more information.  IPython 1.1.0 -- An enhanced Interactive Python. ?         -> Introduction and overview of IPython's features. %quickref -> Quick reference. help      -> Python's own help system. object?   -> Details about 'object', use 'object??' for extra details.  In [1]: import BeautifulSoup --------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) <ipython-input-1-aa1e12a76f5e> in <module>() ----> 1 import BeautifulSoup  ImportError: No module named BeautifulSoup  In [2]: import mrjob --------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) <ipython-input-2-6ea1b9bda48b> in <module>() ----> 1 import mrjob  ImportError: No module named mrjob  In [3]: import pattern --------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) <ipython-input-3-4b662941bac1> in <module>() ----> 1 import pattern  ImportError: No module named pattern  In [4]:  

Funny thing is, these packages can be very well imported when I'm not running the Anaconda bundle of python, after removing

# added by Anaconda 1.8.0 installer export PATH="/home/username/anaconda/bin:$PATH" 

from my .bashrc:

Python 2.7.5+ (default, Sep 19 2013, 13:48:49)  Type "copyright", "credits" or "license" for more information.  IPython 0.13.2 -- An enhanced Interactive Python. ?         -> Introduction and overview of IPython's features. %quickref -> Quick reference. help      -> Python's own help system. object?   -> Details about 'object', use 'object??' for extra details.  In [1]: import BeautifulSoup  In [2]: import mrjob  In [3]: import pattern  In [4]:  

Did I miss anything during any of these installations that I ran? Should I manually link these packages to Anaconda so that it knows where to find them?

like image 212
alxyzc Avatar asked Jan 18 '14 06:01

alxyzc


1 Answers

In the comments, it was determined that the pip in use was /usr/bin/pip; in other words, the system pip. The system pip will install into the system site-packages, not Anaconda's site-packages.

The solution is to make sure you're using Anaconda's pip when installing packages for use with Anaconda.

like image 167
icktoofay Avatar answered Dec 26 '22 18:12

icktoofay