Skip to content

Loading…

Python with Pip - Tries to write to '/Library/Python/2.7/site-packages - Fails #12667

Closed
victorhooi opened this Issue · 20 comments

8 participants

@victorhooi

Hi,

This is on OSX 10.8, with the XCode Command Line Tools installed.

I have used Homebrew to install Python:

brew install python  --universal --framework

I then added the following to my ~/.bash_profile

export PATH="/usr/local/bin:/usr/local/share/python:${PATH}"

I then ran:

sudo easy_install pip

which seemed to work. I check where my pip is installed:

Victors-MacBook-Pro:~ victorhooi$ which pip
/usr/local/bin/pip

However, when I try to use pip to install packages, it seems to insist on writing to /Library/Python/2.7/site-packages, which it can't obviously, so it fails. E.g.:

victor-mbp<1:~ victorhooi$ pip install yolk
...
creating build/lib/yolk/plugins

copying yolk/plugins/__init__.py -> build/lib/yolk/plugins

copying yolk/plugins/base.py -> build/lib/yolk/plugins

running install_lib

creating /Library/Python/2.7/site-packages/yolk

error: could not create '/Library/Python/2.7/site-packages/yolk': Permission denied

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/Users/victorhooi/build/yolk/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/gg/m37t1rkx4zj7z54ls487jfc40000gn/T/pip-MqS3Py-record/install-record.txt failed with error code 1 in /Users/victorhooi/build/yolk
Storing complete log in /Users/victorhooi/Library/Logs/pip.log

My understanding was that Homebrew should write to it's own site-packages in /usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages (https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python).

Is there something special you need to do to get Homebrew's Python to play nicely, and write to it's own folder? (I'd rather not just do blanket chown's around the filesystem to get things to work).

Cheers,
Victor

@adamv

Do you have a ~/.pydistutils.cfg file?

@victorhooi

heya,

Hmm, should I have a ~/.pydistutils.cfg file?

I didn't see anything in the Wiki or in brew info python output about it - the closest was:

==> Caveats
A "distutils.cfg" has been written to:
  /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils
specifing the install-scripts folder as:
  /usr/local/share/python

If you install Python packages via "python setup.py install", easy_install, pip,
any provided scripts will go into the install-scripts folder above, so you may
want to add it to your PATH.

However, that seems it should already automatically all work?

Hmm, I can create a ~/.pydistutils.cfg file - what should I put in it?

I just tried copying that distutils mentioned above into ~/.pydistutils.cfg, doesn't seem to have any effect, pip install virtualenv still fails attempting to write to error: /Library/Python/2.7/site-packages/virtualenv.py: Permission denied.

Cheers,
Victor

@samueljohn

@victorhooi On Lion unfortunately /Library/Python is not writable. Obviously the same holds for 10.8. The is the -U option to install into a user directory, so you don't need sudo.

But I think this related to the bug #12758 that lead to linking our brewed python against the system python. This causes various bugs, for example distutils believes it has to install to /Library/Python because the system's python does so.

There should really be no ~/.pydistutils.cfg. It can cause trouble by overwriting how installation of modules work.

@samueljohn

@victorhooi for now, you can try brew install python --framework. That framework install is more self-contained and does not link against the system python. Does it help?

@samueljohn

Also make sure which easy_install you are using.

Do you really need --universal?

@samueljohn

@victorhooi are you still there?

@samueljohn samueljohn added a commit to samueljohn/homebrew that referenced this issue
@samueljohn samueljohn python: framework is default. ipv6 enabled. Fixed #12581, #12194
- Defaults to a framework style build to support wxmac and other GUIs
  (Note PySide (and pyqt?) seem to work even with non-framework builds).
- Added an option: `--no-framework`
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- #10487 is no longer needed. Has been fixed upstream.
- Check against possible issue like #12667.
- Check against ~/.pydistutils.cfg until #12667 is pulled.
- warn about /Library/Frameworks/Tk.framework if found.

Probably closes #11320 and #12667 by the changes above.

For better readability I reordered the helper methods in the formula.
a859881
@samueljohn samueljohn added a commit to samueljohn/homebrew that referenced this issue
@samueljohn samueljohn python3: framework is default. ipv6 enabled. Fixed #12581, #12194
- Defaults to a framework style build to support wxmac and other GUIs
  (Note PySide (and pyqt?) seem to work even with non-framework builds).
- Added an option: `--no-framework`
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against ~/.pydistutils.cfg until #12667 is pulled.
- warn about /Library/Frameworks/Tk.framework if found.

For better readability I reordered the helper methods in the formula.
3f1aacc
@spenthil

@samueljohn - FWIW, I had the same problem with brew install python

brew install python --framework did work though.

@samueljohn

@spenthil Thanks for the feedback. The same situation is true for me. I fixed it for the non-framework build in this commit but also note that "framework" is the default now.

Sorry for spamming the comments here by. Note to myself: No more mentions of issues in the commit log.

@samueljohn

"framework" is the default now.

And with "now" I mean "when this pull request is pulled"

@mikemcquaid
Homebrew member

@samueljohn If you answer the few issues I raised on the commit I'm personally happy for this to go in.

@samueljohn
@mikemcquaid
Homebrew member

@adamv @mxcl @mistydemeo @samueljohn @jacknagel Any objections to merging this?

@samueljohn

@mikemcquaid by "this" you mean #12968?

@mikemcquaid
Homebrew member

Er, yes.

@samueljohn samueljohn added a commit to samueljohn/homebrew that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.
c24c043
@mikemcquaid mikemcquaid added a commit that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
a97c817
@mikemcquaid
Homebrew member

No reply and a97c817 merged so closing.

@mikemcquaid mikemcquaid closed this
@hmac hmac added a commit that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2346e24
@fgeller fgeller added a commit to fgeller/homebrew that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
e9f3e6f
@Nexuapex Nexuapex pushed a commit that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
f7da710
@ckdaas ckdaas added a commit that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
3f3a40c
@Sharpie Sharpie pushed a commit to Sharpie/homebrew that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
284db52
@snakeyroc3 snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue
@samueljohn samueljohn python: Now framework style. Bug fixes.
- Framework style build in order to support wxmac and other GUIs
  (Note: PySide (and pyqt?) seem to work even with non-framework builds).
- Fixed automatic installation of `*.app`s into `/Applications`.
- The caveats tell us now about `brew link apps`.
- Cleanup of the caveats.
- Resolve the issue of duplicate `2to3` can make the symlink phase
  to break because both python and python3 provide it. (Closes #12581)
- Enable warnings, because python's configure needs it. (Closes #12194)
- Add suppression of recommended warnings from the python docs.
- Add work-a-round for python bug: http://bugs.python.org/issue11445
- Add explicit test if sqlite3 built successful.
- Check against possible issue like #12667.
- Add needed "depends_on :x11" because tk.h includes x11.
- Install the Demo into HOMEBREW_PREFIX/share/python2.7/Extras
- Ensure sqlite from homebrew is used and not the one from OS X.
- Removed unnecessary flags from configure
- Added --without-gcc to the configure flags (all clang now)
- Ensure that "man python2.7" works by setting --datadir and --datarootdir to share.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
ff08e9d
@armw4

~/.pydistutils.cfg will force you to use sudo if present. I forget why I needed it, but once I whacked it, things worked fine with pip.

Before:

error: could not delete '/lib/python2.7/site-packages/virtualenv.py': Permission denied

After:

Installing virtualenv script to /usr/local/bin
Installing virtualenv-2.7 script to /usr/local/bin
Successfully installed virtualenv
@samueljohn

Didn't we have a doctor warning if that file is present or is it just that I wanted to add one?

@armw4
@diimdeep

Just had same problem with pip install pandas solve with brew install python --framework
I think we should add about this in Caveats.

@tdsmith
Homebrew member

--framework no longer does anything; your problem must have been unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.