Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Brewed pip tries to write to /lib, fails under El Capitan #44836

Closed
pedrovanzella opened this issue Oct 11, 2015 · 5 comments
Closed

Brewed pip tries to write to /lib, fails under El Capitan #44836

pedrovanzella opened this issue Oct 11, 2015 · 5 comments
Labels

Comments

@pedrovanzella
Copy link
Contributor

I updated to El Capitan and fixed homebrew. I can install formulae just fine. Problem is, pip install anything fails, same as pip3 install anything.

Collecting setuptools
  Downloading setuptools-18.4-py2.py3-none-any.whl (462kB)
    100% |████████████████████████████████| 462kB 43kB/s
Installing collected packages: setuptools
  Found existing installation: setuptools 18.3.1
    Uninstalling setuptools-18.3.1:
      Successfully uninstalled setuptools-18.3.1
  Rolling back uninstall of setuptools
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/lib/python2.7/site-packages/easy_install.py'

pip3 fails in a similar manner:

Collecting nose
  Downloading nose-1.3.7-py3-none-any.whl (154kB)
    100% |████████████████████████████████| 155kB 2.1MB/s
Installing collected packages: nose
  Found existing installation: nose 1.3.4
    Uninstalling nose-1.3.4:
      Successfully uninstalled nose-1.3.4
  Rolling back uninstall of nose
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.5/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/usr/local/lib/python3.5/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/usr/local/lib/python3.5/site-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/local/lib/python3.5/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python3.5/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python3.5/site-packages/pip/wheel.py", line 282, in clobber
    ensure_dir(dest)  # common for the 'include' path
  File "/usr/local/lib/python3.5/site-packages/pip/utils/__init__.py", line 71, in ensure_dir
    os.makedirs(path)
  File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py", line 231, in makedirs
    makedirs(head, mode, exist_ok)
  File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/lib/python3.5'

It seems to be either trying to read from or write to /lib, which is not allowed by SIP, nor does it even exist in El Capitan.

I've tried to re-install python 2 and python 3, and that didn't help.

Trying to install to a virtualenv yields the same result, which is even worse. I see no reason why pip should ever come close to /lib.

@DomT4
Copy link
Member

DomT4 commented Oct 12, 2015

Homebrew certainly wouldn't be supporting it needing to write to a root-necessary directory given half the point of brew is to not force root for every operation under the sun on every Tom, Sally or Michelle.

I haven't seen this anywhere else yet, so perhaps something is awry locally. Can you brew config & brew doctor? Thanks.

@DomT4 DomT4 added the python label Oct 12, 2015
@pedrovanzella
Copy link
Contributor Author

brew config:

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: 40e3d975db68d67c9cf394c174ad4207235d2e8d
Last commit: 12 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit sandybridge
OS X: 10.11-x86_64
Xcode: 7.0.1
CLT: N/A
couldn't understand kern.osversion `15.0.0'
GCC-4.2: build 5666
Clang: 7.0 build 700
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p645
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /Users/pedrovanzella/.rbenv/shims/ruby => /Users/pedrovanzella/.rbenv/versions/2.2.3/bin/ruby
Java: 1.8.0_25, 1.8.0_05

brew doctor:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

Warning: A .pydistutils.cfg file was found in $HOME, which may cause Python
builds to fail. See:
  https://bugs.python.org/issue6138
  https://bugs.python.org/issue4655

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libCGF.dylib
    /usr/local/lib/libgnuradio-osmosdr.0.1.5git.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/osmosdr/api.h
    /usr/local/include/osmosdr/device.h
    /usr/local/include/osmosdr/pimpl.h
    /usr/local/include/osmosdr/ranges.h
    /usr/local/include/osmosdr/sink.h
    /usr/local/include/osmosdr/source.h
    /usr/local/include/osmosdr/time_spec.h

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
    /usr/local/lib/pkgconfig/gnuradio-osmosdr.pc

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    gnupg2
    gpg-agent

@pedrovanzella
Copy link
Contributor Author

Got it fixed!

I had a /Library/Frameworks/Python.framework, which I removed, and a ~/.pydistutils.cfg, which I also removed. That fixed everything.

@DomT4
Copy link
Member

DomT4 commented Oct 12, 2015

Great! Glad things are working again 😃. brew doctor does quite a few Python-related checks so it's worth checking there if you run into things.

@jbnunn
Copy link

jbnunn commented May 27, 2016

I didn't have /Library/Frameworks/Python.framework, but removing ~/.pydistutils.cfg fixed for me as well

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants