3

I have a virtualenv with Python 2.7 and I'm trying to install some packages that have C extensions (in this case, pygame and/or pyaudio):

$ which pip
/Users/fyhuang/env/bin/pip
$ pip -V
pip 1.4 from /Users/fyhuang/env/lib/python2.7/site-packages (python 2.7)

When I try to install these packages, however, pip decides that it wants to install the compiled C extensions into the system directories, instead of the virtualenv:

running install_lib

creating /lib

error: could not create '/lib': Permission denied

Is this expected behavior from pip? If not, has anyone else run into this issue before? This is on OSX 10.8.

fyhuang
  • 2,147
  • 5
  • 21
  • 24
  • I also see this behavior on 10.9, using either the default system python 2.7.5 or homebrew python 3.3.4, whether or not I'm using virtualenv. Would love to find a solution... – Mike Feb 19 '14 at 16:46
  • And not just with pip, but also with a straight `python setup.py install`. It seems to be a `setuptools` issue. – Mike Feb 19 '14 at 18:17

1 Answers1

3

Figured out a workaround. I had previously seen this question/answer on SO:

Combine --user with --prefix error with setup.py install

Which suggested the creation of a ~/.pydistutils.cfg file to solve the --user problem. However, that file also creates incorrect behavior (as above) for installing packages with C extensions into --user. A better workaround is to, instead of having the ~/.pydistutils.cfg file, call pip with the following arguments:

pip install --user --install-option="--prefix" pygame

That installs pygame into --user without messing up the C extension install directories, at least on OSX.

Community
  • 1
  • 1
fyhuang
  • 2,147
  • 5
  • 21
  • 24