Search code examples
pythoneasy-install

How do I get easy_install to install modules to the correct directory?


I am trying to install a new module with easy_install.

When I run a command like

sudo easy_install foo

foo gets installed to ~/Library/Python/2.7/site-packages/.

This seems to be wrong since I can't use any of the installed modules from within my python shell.

From what I have understood after reading through some SO posts related to easy_install issues the correct directory should be /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages , since my python shell uses /usr/local/bin/python which is symbolically linked to said directory.

How do I tell easy_install to use this directory rather then the current one?

Thank you,

Julian

EDIT: I reran the setuptools installation with the option -d /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages. The output was as follows:

Processing setuptools-0.6c11-py2.7.egg
Removing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Installing easy_install-2.7 script to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

The output of e.g. sudo easy_install mechanize is

Searching for mechanize
Best match: mechanize 0.2.5
Processing mechanize-0.2.5-py2.7.egg
mechanize 0.2.5 is already the active version in easy-install.pth

Using /Users/julian/Library/Python/2.7/site-packages/mechanize-0.2.5-py2.7.egg
Processing dependencies for mechanize
Finished processing dependencies for mechanize

It seems that easy_install is still using the wrong directory?! Help is highly appreciated. Thank you.


Solution

  • It turns out that I was having an issue with my PATH. Moving /usr/local/share/python to the top of my PATH and reinstalling python through homebrew fixed my problems.

    In case the problem persists, definitely try running brew doctor and follow the advice there!