Reputation: 403
I'm using Mac OS X 10.10. I want to use pip to install packages for my homebrew installed version of python (located in /usr/local/bin/python
, which is an alias that points to /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin
). It appears that site-packages for this version are here: /usr/local/lib/python2.7/site-packages/
.
which python
returns /usr/local/bin/python
which pip
returns /usr/local/bin/pip
These seem correct to me.
Trying something like pip install pylzma
returns:
Collecting pylzma
Installing collected packages: pylzma
Successfully installed pylzma
You are using pip version 8.0.2, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But then pip list
does not show pylzma
to be installed. It looks like pip installs the packages to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
(the python that ships with Mac OS X).
How can I get pip to install to my homebrewed python?
I've tried a number of suggestions from similar questions:
export PATH=/usr/local/bin/python:${PATH}
.pip install --install-option="--prefix=/usr/local/lib/python2.7" pylzma
.#!/usr/local/bin/python
/usr/local/bin/python -m pip install pylzma
.But none of these work. I also tried upgrading pip to 8.1.1, but that made pip break entirely. People recommend using virtualenv
, but as far as I know, I can't install that without pip.
When I type python -m pip
, it says:
Usage:
/usr/local/opt/python/bin/python2.7 -m pip <command> [options]
Could that be a problem?
Upvotes: 4
Views: 3141
Reputation: 403
My issue was that my /Users/<username>/.pydistutils.cfg
contained the following:
[easy_install]
# set the default location to install packages
install_dir = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
[install]
install_lib = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
install_scripts = ~/bin
I changed this to:
[easy_install]
# set the default location to install packages
install_dir = /usr/local/lib/python2.7/site-packages
[install]
install_lib = /usr/local/lib/python2.7/site-packages
install_scripts = ~/bin
That seemed to have worked. pip install
now installs packages to the desired location /usr/local/lib/python2.7/site-packages
.
However, I am have ongoing path issues.
import pylzma
still gives me ImportError: No module named pylzma
.
and running jupyter notebook
in terminal gives -bash: jupyter: command not found
. /Users/<username>/bin/jupyter notebook
does execute, but I get ImportError: No module named markupsafe
despite the fact that /usr/local/lib/python2.7/site-packages/MarkupSafe-0.23.dist-info
exists.
EDIT: I got jupyter notebook working eventually. I had to install several packages from the source tarballs directly, including MarkupSafe, functools32, and jsonschema. Maybe Python is not looking in the correct folder or something.
Upvotes: 2