This repository has been archived by the owner. It is now read-only.

Permission Denied Error when 'brew install python' #16303

Closed
dark9t opened this Issue Nov 29, 2012 · 75 comments

Comments

Projects
None yet

dark9t commented Nov 29, 2012

Tried brew doctor and brew update. The error still persisted. Here is the error part of the installation log:

==> Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.30.tar.gz
==> /usr/local/Cellar/python/2.7.3/bin/python -s setup.py --no-user-cfg install --
File "/private/tmp/UNKNOWN-Id1h/distribute-0.6.30/distribute_setup.py", line 355, in _patch_egg_dir
_rename_path(path)
File "/private/tmp/UNKNOWN-Id1h/distribute-0.6.30/distribute_setup.py", line 266, in _rename_path
os.rename(path, new_name)
OSError: [Errno 13] Permission denied

Thank you for your help!

Contributor

mistydemeo commented Nov 29, 2012

Can you please paste the output of brew doctor? Please follow the instructions for filing a new bug here as well, thanks! https://github.com/mxcl/homebrew/wiki/Troubleshooting

Contributor

samueljohn commented Dec 3, 2012

Please also provide the full output of brew install -v python in a gist.github.com. Then I can tell more. My bet is that a wrong python is picked up and tries to install the distribute package in a dir where you need sudo. But then this indicates that your configuration (PATH?) would be wrong.

dark9t commented Dec 4, 2012

@mistydemeo : Hi Misty, thank you for your help. my 'brew doctor' output shows no problem, saying "Your system is raring to brew."

@samueljohn : Thank you. Here is the dump of the command you suggested. https://gist.github.com/4200501

Contributor

samueljohn commented Dec 4, 2012

Thanks @dark9t. Unfortunately, I can't get a clue out of the gist. Seems like the install of distribute fails. You could try to delete /usr/local/lib/python2.7 and then try to reinstall - but this is just a guess.

Contributor

samueljohn commented Dec 4, 2012

@dark9t you don't happen to have set a PYTHONHOME or something? Anything you could think of?

Contributor

samueljohn commented Dec 4, 2012

I think I found a fix - will open a PR soon.

Contributor

samueljohn commented Dec 4, 2012

Fuck. Wrong window. No - I havn't found a fix (that was the vtk thing). Sorry all.

Contributor

samueljohn commented Dec 4, 2012

Can you try again, I saw we have distribute-0.6.32.tar.gz now and in your test, you have /distribute-0.6.30.tar.gz.
Don't know if this makes a difference.

If that does not help, can you wipe out (or move to a save place) your $(brew --prefix)/lib/python2.7/site-packages/ dir? That dir is not removed if you brew rm python, so perhaps some remains of older attempts are still left.

Any update on this? I'm seeing this error as well.

Contributor

samueljohn commented Dec 12, 2012

@weeewake the "OSError: [Errno 13] Permission denied" thing? Can you please gist.github.com the output of brew install --verbose python after you brew rm python && rm -r $(brew --prefix)/lib/python2.7.

Contributor

samueljohn commented Dec 12, 2012

@dark9t you still have this problem?

I was having this problem as well. I went into my old /Library/Python/2.7 directory and nuked the site-packages directory and it fixed it. I had some stuff in there from before I knew what I was doing with Python (well, I still don't know what I'm doing, but I knew even less then). It looked like Homebrew was finding something in there (possibly setuptools-0.6c11-py2.7.egg) and trying to use it instead of its own copy. Hope this helps. Here's a link to the gist of the relevant output from brew install --verbose python: https://gist.github.com/4436231.

Contributor

samueljohn commented Jan 2, 2013

Thanks @davidthelazar ... indeed that is an issue and I already know if it. I thought I fixed that by especially removing all items from Python's sys.path that start with /System when a brewed Python is present (look in the /usr/local/lib/python2.7/site-packages/sitecustomize.py file).

However, I don't want to remove /Library/Python/2.7 because its a feature that you can import Python packages from there.

I guess I have to think harder and perhaps move Homebrew's Python site-packages to the first position in sys.path.

Contributor

samueljohn commented Jan 16, 2013

I think I found a fix for this. Adding -S to the python setup.py call, right after python, results in the site module being skipped and therefore the /Library/Python... is not in the path, so distribute can install even if there is an old easy_install (setuptools flying around). I will open a PR in the next iteration, since this is not so pressing right now.

Contributor

adamv commented Jan 30, 2013

@samueljohn: close this particular error then?

Contributor

samueljohn commented Jan 30, 2013

@adamv not yet, hope to open my PR later this day (CET) with my new PythonInstalled requirement where I fix some minor things (such as this issure here, too).

rhblind commented Feb 14, 2013

I have this issue as well.
As a temporary solution I chown'ed /usr/local/bin/brew to root, then sudo installed python, then chmod -R /usr/local back to my own user.

Not ideal, but at least I got python installed with no errors..

Contributor

samueljohn commented Feb 15, 2013

No that is really a bad hack. Now you have all files of python installed as root. You should chown -R <youeruser> /usr/local otherwise the next brew upgrade or perhaps pip install... or other things may give you permission errors, too.

Probably you had either installed python once with sudo or you had the "official" python installer from python.org that prompts for you password and installs as root into /usr/local/bin!

rhblind commented Feb 15, 2013

Yes, I know it's a really bad hack, but it's better than having no brewed python at all ;)

I was probably a bit unclear; Yes, I did install as root, and all python files was installed as root, but I changed ownership back to my own user (chown -R $(whoami) /usr/local) once installed, so now I own them again.

I had a completely clean /usr/local and installed the newest homebrew, but python install failed with same error as the original post here.
Otherwise, thanks for a great piece of software!

Contributor

samueljohn commented Feb 15, 2013

@rhblind okay then :-)
Yes, I should add the -S to the call of python -S setup.py... because I bet you have a setuptools/easy_install at either /Library/Python/2.7/site-packages or ~/Library/Python/2.7/lib/python/site-packages. Strangely somehow that setuptools installation takes precedence because of python's built-in search strategy...

rhblind commented Feb 15, 2013

That's right, I have setuptools installed in /Library/Python/2.7/site-packages. That's what causing the problem?
In that case, the -S flag sounds like a good idea. I know I'm not the only one with this problem ;)

Besides, there's no reason you would like to use the /Library/Python/2.7/site-packages setuptools in a brand new python install.

Contributor

samueljohn commented Feb 15, 2013

Besides, there's no reason you would like to use the /Library/Python/2.7/site-packages setuptools in a brand new python install.

It's a dilemma, on the one side, that setuptools there is a mess (but if you only use pip with your new python, it should be fine) on the other hand, I don't want to disable the whole /Library/Python/2.7/site-package because it is a feature to put (pure python) modules there which can be imported from all python 2.7 binaries on you Mac.

I'm basically having the same issue. Is there a resolution?

Here's my output: https://gist.github.com/satmandu/5042446

Contributor

samueljohn commented Feb 27, 2013

@satmandu your issue is different. You did probably sudo brew python some time ago.

You should probably do something like chown -R <YOURUSER> /usr/local and chmod -R +rw /usr/local.

tclose commented Mar 7, 2013

Any update on this?

My work around was to temporarily move setuptools and the setuptools egg somewhere else, then run "brew install python". Will there be any side effects caused by doing this?

tclose commented Mar 7, 2013

I should add that I was having the same problem as rhblind, where brew was finding my /Library/Python/2.7/site-packages/setuptools

Contributor

samueljohn commented Mar 15, 2013

@tclose can you brew edit python and change

Distribute.new.brew { system "#{bin}/python", *setup_args }

into

Distribute.new.brew { system "#{bin}/python", "-S", *setup_args }

Then brew install python and tell me if it is working?
I assume yes, but not 100% sure. -S is a python switch that disables the site-packages temporary.

I assume you know how you can change back the modifications later one via git? cd $(brew --prefix) && git checkout -- Library/Formula/python.rb (should do the trick)

@ghost ghost assigned samueljohn Mar 15, 2013

tclose commented Mar 17, 2013

Hi Samuel,

I don't have access to the system i was having the problem with at the
moment but might be able to have a look at it towards the end of next week,

Cheers,

Tom

On 16/03/2013, at 12:29 AM, Samuel John notifications@github.com wrote:

@tclose https://github.com/tclose can you brew edit python and change

Distribute.new.brew { system "#{bin}/python", *setup_args }

into

Distribute.new.brew { system "#{bin}/python", "-S", *setup_args }

Then brew install python and tell me if it is working?
I assume yes, but not 100% sure. -S is a python switch that disables the
site-packages temporary.

I assume you know how you can change back the modifications later one via
git? cd $(brew --prefix) && git checkout --
Library/Formula/python.rb(should do the trick)


Reply to this email directly or view it on
GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-14967048
.

Contributor

samueljohn commented Mar 19, 2013

The -S flag will be added in #18588, too.

samueljohn's fix worked for me, but now brew's pip conflicts with the system one.

I'm having real problems installing Python 2.7.4

brew doctor says Your system is raring to brew.

Here's my brew config : https://gist.github.com/neilalbrock/5349352
and the result of brew install --verbose python : https://gist.github.com/neilalbrock/5349384

Any help would be much appreciated.

I finally got the install to work by clearing /Library/Python/2.7/site-packages, I'd previously tried the -S option mentioned earlier in this thread but it failed with an error locating setuptools. Anyway, everything seems fine now.

Contributor

samueljohn commented Apr 10, 2013

Thanks for your report and the suggest work-a-round.

@samueljohn I got this permission error too, I don't know what's going on here! is this fixed? I pasted the error output as below

==> /usr/local/Cellar/python/2.7.4/bin/python -s setup.py --no-user-cfg install
File "/private/tmp/UNKNOWN-1EIF/distribute-0.6.36/distribute_setup.py", line 360, in _patch_egg_dir
_rename_path(path)
File "/private/tmp/UNKNOWN-1EIF/distribute-0.6.36/distribute_setup.py", line 271, in _rename_path
os.rename(path, new_name)
OSError: [Errno 13] Permission denied

my brew doctor shows the system is ready to brew and brew update works like a charm.

Contributor

samueljohn commented May 3, 2013

It's hard to fix for us because we don't want to disable that Python looks in /Library/Python/... or ~/Library/Python for shared packages. However a setuptools sitting there sucks a lot and I have not found a good way to fix that, yet. Open for suggestions. Probably, I'll make the brew doctor complain if it finds a setuptools installation in that place.

@samueljohn so, now the best way to fix this is to clean up the Python and everything it comes with macOS?

Contributor

samueljohn commented May 4, 2013

Do not remove the system python. Don't ever do this. Mac OSX may depend on it.

But ~/Library/Python/2.7/site-packages and /Library/Python/2.7/site-packages can be savely emptied. They are empty (except for the readme) on a fresh OS X.

@samueljohn ok, roger that

Emptying both ~/Library/Python/2.7/site-packages and /Library/Python/2.7/site-packages did it for me. Thanks @samueljohn 👍

Not sure why I'm receiving these emails, but anyway let me strongly advise against lightly removing the whole site-packages directory. Anyone considering doing so must realize beforehand that when doing so, he will loose all custom installed python packages. For instance, if one has installed numpy, scipy, matplotlib, ipython, etc, he will loose it all after emptying site-packages.

Best,
Rodrigo Ventura

On 22/05/2013, at 05:40, Carlos Iriarte wrote:

Emptying both ~/Library/Python/2.7/site-packages and /Library/Python/2.7/site-packages did it for me. Thanks @samueljohn


Reply to this email directly or view it on GitHub.

Rodrigo Ventura
Institute for Systems and Robotics
Instituto Superior Técnico
Lisbon, Portugal
http://users.isr.ist.utl.pt/~yoda

this issue is really pain in the s. hope will get fixed soon

Contributor

samueljohn commented May 22, 2013

We can only work-around. Fixing this is up to python/distribute/pip/easy_install.

And, yes, removing the content of site-packages is the last thing I recommend.

Note, I maintain a tap for numpy, SciPy, matplotlib and other python formulae that don't build easily with pip, so installing these should be less pain.

Contributor

adamv commented May 22, 2013

What will it take to close this issue? I don't like keeping issues open for a long time just to serve as documentation of a workaround.

Contributor

samueljohn commented May 22, 2013

I'll move this one to the top of my todo list.

Contributor

adamv commented May 22, 2013

Sorry, I don't mean to randomize your list.

Contributor

samueljohn commented May 23, 2013

Ok, the best I can do, is to add a very precise brew doctor check telling to remove the offending setuptools installation (will need admin rights).

I think a setuptools installation, for example like /Library/Python/2.7/site-packages/setuptools-0.6c12dev_r88846-py2.7.egg-info is the cause of this problem. The newer distribute needs to rename it because the more modern distribute provides the same functionality. Since that dir (/Library/Python/2.7/site-packages/) needs admin rights to write to, the renaming distribute attempts fails.

Anyone still having this problem, could you please post me these lines:

Scanning installed packages
Setuptools installation detected at /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg
Egg installation
Patching...
Renaming /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg to /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1357145182.72

from your brew install python -v output? The exact name will differ. I am interested in the exact filename of that setuptools. It could perhaps also be a setuptools.pth file or something.
Then I'll make a better brew doctor check.

here is the exact file name in my system

setuptools-0.6c11-py2.7.egg
setuptools.pth

Contributor

samueljohn commented May 26, 2013

Thanks @HughGrant!

Contributor

mistydemeo commented Jun 16, 2013

@samueljohn What's the status of this?

theseion commented Jul 2, 2013

Scanning installed packages
Setuptools installation detected at /Library/Python/2.7/site-packages/setuptools-0.6c12dev_r88846-py2.7.egg
Egg installation
Patching...
Renaming /Library/Python/2.7/site-packages/setuptools-0.6c12dev_r88846-py2.7.egg to /Library/Python/2.7/site-packages/setuptools-0.6c12dev_r88846-py2.7.egg.OLD.1372794939.13

I have this problem as well. Mine seems to be caused by a version in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Scanning installed packages
Setuptools installation detected at /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Non-egg installation
Moving elements out of the way...
Renaming /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools-0.6c12dev_r88846-py2.7.egg-info to /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools-0.6c12dev_r88846-py2.7.egg-info.OLD.1373057994.08
Traceback (most recent call last):
..
File "/private/tmp/UNKNOWN-orSS/distribute-0.6.45/distribute_setup.py", line 281, in _rename_path
os.rename(path, new_name)
OSError: [Errno 13] Permission denied

UPDATE:
Erased the disk and reinstalled OS X 10.8 and updated to 10.8.4.
Problem files are present.
Install CL Tools and Homebrew.

brew install readline sqlite gdbm
brew install -v python

Install works fine. Not sure what caused the issue, but it's not happening for a clean install.

If you don't want to do this, you can always temporarily rename the files and that will work too.

russkel commented Jul 6, 2013

Oddly enough I installed python fine the first time, but I brew uninstall python and then brew install python --with-brewed-tk.

==> /usr/local/Cellar/python/2.7.5/bin/python2 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.5/bin --install-lib=/usr/local/lib/python2.7/site-packages
/usr/local/Cellar/python/2.7.5/bin/python2 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.5/bin --install-lib=/usr/local/lib/python2.7/site-packages
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /usr/local/lib/python2.7/site-packages
Non-egg installation
Moving elements out of the way...
Renaming /usr/local/lib/python2.7/site-packages/setuptools-0.8-py2.7.egg-info to /usr/local/lib/python2.7/site-packages/setuptools-0.8-py2.7.egg-info.OLD.1373100612.12
Traceback (most recent call last):
  File "setup.py", line 134, in <module>
    _before_install()
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 386, in _before_install
    _fake_setuptools()
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 443, in _fake_setuptools
    res = _remove_flat_installation(setuptools_location)
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 241, in __no_sandbox
    return function(*args, **kw)
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 301, in _remove_flat_installation
    patched = _patch_egg_dir(pkg_info)
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 241, in __no_sandbox
    return function(*args, **kw)
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 370, in _patch_egg_dir
    _rename_path(path)
  File "/private/tmp/__UNKNOWN__-Ieas/distribute-0.6.45/distribute_setup.py", line 281, in _rename_path
    os.rename(path, new_name)
OSError: [Errno 13] Permission denied

Hmm. For some reason setuptools belongs to root in that directory. This may have been me accidently running sudo pip instead of pip.

Hi Russ,

(1) I didn't look through all the comments on this thread and failed to see that it's been closed.
You may want to find another approach on this.

(2) I did a clean install of OS X and still have these setuptools files

cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
ls -d setuptools*
setuptools setuptools-0.6c12dev_r88846-py2.7.egg-info

so I believe they are Apple-supplied.

(3) My original output from brew install -v python showed a problem with renaming setuptools in this directory
(/System .. ), but after the clean install this no longer happens. No idea why.

(4) The output from your build shows that the error is with

Renaming /usr/local/lib/python2.7/site-packages/setuptools-0.8-py2.7.egg-info

i.e. it is not the System .. directory but /usr/local ..
This indicates that your /usr/local is not writeable by you. This is easily fixable.

Tom


From: Russ Webber [notifications@github.com]
Sent: Saturday, July 06, 2013 4:45 AM
To: mxcl/homebrew
Cc: Elliott, Thomas
Subject: Re: [homebrew] Permission Denied Error when 'brew install python' (#16303)

Oddly enough I installed python fine the first time, but I brew uninstall python and then brew install python --with-brewed-tk.

I checked the /Library/Python/2.7/site-packages/ dir and removed the setuptools files in there. Retried, same error. So I have a look in System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/ and sure enough:

Samorost:python russ$ ls | grep setuptools
setuptools-0.6c12dev_r88846-py2.7.egg-info
setuptools-0.6c12dev_r88846-py2.7.egg-info.OLD.1364093774.05
setuptools.OLD.1364093774.05

It seems there might be an issue on renaming the files back?


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-20551284.

russkel commented Jul 7, 2013

Hi Tom,

Thanks for writing back. I edited my reply after the email was sent to you (so you got an old message). I am pretty sure it was due to me running sudo pip instead of just pip, causing setuptools to belong to root.

Regards,

Russ

I have a diagnosis of this problem but don't feel confident enough to fix it myself. The problem is caused by the Formula for Python also installing distribute. distribute is trying to modify setuptools (since it wraps them), but in directories where it has no business doing so. In my case
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
and fails with a permissions error, which is a good thing.

Since distribute is deprecated (see recent setuptools or
http://www.macports.org/ports.php?by=name&substr=distribute)
it seems an appropriate solution would be to replace distribute in python.rb with a recent version of setuptools
https://pypi.python.org/pypi/setuptools/0.8#id1

russkel commented Jul 7, 2013

Apparently the latest version of distribute is just a compatibility wrapper
than installs setuptools anyway (see:
https://pypi.python.org/pypi/distribute/0.7.3).

I agree that the formula should be changed and distribute should be
replaced with setuptools. Problem is I don't think that's going to solve
the problem as I believe the bug is in setuptools.

On 7 July 2013 19:32, telliott99 notifications@github.com wrote:

I have a diagnosis of this problem but don't feel confident enough to fix
it myself. The problem is caused by the Formula for Python also installing
distribute. distribute is trying to modify setuptools (since it wraps
them), but in directories where it has no business doing so. In my case
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
and fails with a permissions error, which is a good thing.

Since distribute is deprecated (see recent setuptools or
http://www.macports.org/ports.php?by=name&substr=distribute)
it seems an appropriate solution would be to replace distribute in
python.rb with a recent version of setuptools
https://pypi.python.org/pypi/setuptools/0.8#id1


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-20569438
.

Contributor

iMichka commented Jul 7, 2013

FYI there is some work ongoing for the setuptools/distribute thing #21017

russkel commented Jul 7, 2013

Look at that. Okay the bug might not be in setuptools. Didn't realise the
version of distribute in the formula was so old.

On 7 July 2013 19:43, iMichka notifications@github.com wrote:

FYI there is some work ongoing for the setuptools/distribute thing #21017mxcl#21017


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-20569534
.

Contributor

samueljohn commented Jul 7, 2013

OS X does not come with setuptools but if you sudo easy_install <something> it may install setuptools into /Library and/or /System/Library which is bad because all Pythons have those paths hard-coded in their sys.path. So if brew installs distribute (or soon the newly merged setuptools) it conflicts with the one installed via sudo easy_install <something> even if homebrew installs python modules into $(brew --prefix)/lib/python2.7/site-packages. This is how distribute was coded - it attempts to remove an older setuptools it finds in any of the dirs that are in sys.path.

I will review the pull request #21017 and I encourage you to test if that new setuptools still has the habit to remove an older setuptools it finds anywhere on the sys.path.

Umm, this is just after I erased the disk and did a clean install and update to OS X 10.8.4 (nothing else)

$ cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
$ ls -dal setup*
drwxr-xr-x 20 root wheel 680 Jun 20 2012 setuptools
drwxr-xr-x 8 root wheel 272 Jun 20 2012 setuptools-0.6c12dev_r88846-py2.7.egg-info

Also, I don't find /System/Library.. in sys.path for the Python I just installed with Homebrew, just /Library/Python/2.7/site-packages

Contributor

samueljohn commented Jul 7, 2013

Ok, I think the one at /System is okay because /System/.../site-packages is not in the sys.path for all pythons, initially. But if in /Library/Python/.../site-pakages there is a setuptools.pth or easy_install.pth (or similar) file which includes the setuptools installed at /System/... then it is found by distribute and distribute can't install, because the permission to remove the older installation is denied.
At least I had this once.

I"m new to homebrew and was not able to figure out from the earlier messages what I should do. I am getting the same error message, "Permission denied - /usr/local/lib/python2.7/site-packages/sitecustomize.py", when I try to do either "brew install python" or "brew install git". Is there a solution to this?

russkel commented Jul 22, 2013

@deaneyang please paste the output of ls -l /usr/local/lib/python2.7/site-packages/ | grep sitecustomize.py.

It returns nothing. Here is a full listing of that directory:

deanes-air:homebrew dyang$ ls -l /usr/local/lib/python2.7/site-packages/
total 8
drwxr-xr-x 7 root wheel 238 Feb 29 2012 git_remote_helpers
-rw-r--r-- 1 root wheel 271 Feb 29 2012
git_remote_helpers-0.1.0-py2.7.egg-info

On Mon, Jul 22, 2013 at 7:52 PM, Russ Webber notifications@github.comwrote:

@deaneyang https://github.com/deaneyang please paste the output of ls
-l /usr/local/lib/python2.7/site-packages/ | grep sitecustomize.py.


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-21384513
.

Here's some more information: When I do "brew install python", I get at the
start:

dyld: DYLD_ environment variables being ignored because main executable
(/usr/bin/sudo) is setuid or setgid

On Mon, Jul 22, 2013 at 11:08 PM, Deane Yang <
deane.at.deaneyang.com@gmail.com> wrote:

It returns nothing. Here is a full listing of that directory:

deanes-air:homebrew dyang$ ls -l /usr/local/lib/python2.7/site-packages/
total 8
drwxr-xr-x 7 root wheel 238 Feb 29 2012 git_remote_helpers
-rw-r--r-- 1 root wheel 271 Feb 29 2012
git_remote_helpers-0.1.0-py2.7.egg-info

On Mon, Jul 22, 2013 at 7:52 PM, Russ Webber notifications@github.comwrote:

@deaneyang https://github.com/deaneyang please paste the output of ls
-l /usr/local/lib/python2.7/site-packages/ | grep sitecustomize.py.


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-21384513
.

Contributor

samueljohn commented Jul 23, 2013

You should chown /usr/local or set the rights such that your user can write there. Does the brew doctor not complain about the rights?

Not only does brew doctor not complain but I successfully installed other
software into /usr/local/ using brew. Is there something special about
python27?

On Tue, Jul 23, 2013 at 5:54 PM, Samuel John notifications@github.comwrote:

You should chown /usr/local or set the rights such that your user can
write there. Does the brew doctor not complain about the rights?


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/16303#issuecomment-21448994
.

Contributor

samueljohn commented Jul 24, 2013

Your /usr/local/lib/python2.7/site-packages should be writable by your user otherwise homebrew can't place the sitecustomize.py there. What are your rights, @deaneyang ?

Have you set any DYLD or DYLIB variables?

Contributor

samueljohn commented Aug 27, 2013

Anyone here still having this issue? Setuptools, that is installed by brew, is now at version 1.0 and I hope they have fixed this behavior by now? Any problems?

Contributor

adamv commented Sep 12, 2013

Optimistically saying that the current state of the Python formula more or less does the correct thing now.

@adamv adamv closed this Sep 12, 2013

mazina commented Feb 20, 2014

I had the same error today. My permission error was for /usr/local/lib/python2.7/site-packages/. Inside was a single directory, lcm. I had write permission, and there were no DYLD or DYLIB variables set. Brew doctor did not complain before or after attempted installs. There was no existing site-customize file.

~/Soar/SoarSandbox> brew install python --universal --with-brewed-tk
==> Installing dependencies for python: pkg-config, sqlite, gdbm
==> Installing python dependency: pkg-config
==> Downloading http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/pkg-config/0.28 --disable-host-tool --with-internal-glib --with-pc-path=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/local/Lib
==> make
==> make check
==> make install
/usr/local/Cellar/pkg-config/0.28: 10 files, 604K, built in 43 seconds
==> Installing python dependency: sqlite
==> Downloading http://sqlite.org/2014/sqlite-autoconf-3080300.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/sqlite/3.8.3 --enable-dynamic-extensions
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include

==> Summary
/usr/local/Cellar/sqlite/3.8.3: 9 files, 3.4M, built in 40 seconds
==> Installing python dependency: gdbm
==> Downloading http://ftpmirror.gnu.org/gdbm/gdbm-1.11.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gdbm/1.11 --mandir=/usr/local/Cellar/gdbm/1.11/share/man --infodir=/usr/local/Cellar/gdbm/1.11/share/info
==> make install
/usr/local/Cellar/gdbm/1.11: 16 files, 636K, built in 13 seconds
==> Installing python
==> Downloading http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
######################################################################## 100.0%
==> Patching
patching file setup.py
Hunk #1 succeeded at 1859 (offset 49 lines).
Hunk #2 succeeded at 1904 (offset 49 lines).
Hunk #3 succeeded at 1928 (offset 49 lines).
==> ./configure --prefix=/usr/local/Cellar/python/2.7.6 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.6/share --datadir=/usr/local/Cellar/python/2.7.6/share --enable-framework=/usr/local/Ce
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.6
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.6/share/python
Error: Permission denied - /usr/local/lib/python2.7/site-packages/sitecustomize.py
/Library/Python/2.7/site-packages> cd /usr/local/lib/python2.7/
(M=5820e) /usr/local/lib/python2.7> cd site-packages/
(M=5820e) /usr/local/lib/python2.7/site-packages> ls
lcm
1 (M=5820e) /usr/local/lib/python2.7/site-packages> ls lcm
__init__.py __init__.pyc    __init__.pyo    _lcm.la     _lcm.so

I was finally able to get around this issue by renaming /usr/local/lib/python2.7, installing python via homebrew, then copying the lcm directory from the renamed python directory into the new one created by homebrew.

MikeiLL commented Jan 4, 2016

Same issue here. I also renamed /usr/local/lib/python2.7, brew install python and moved thesite-packages` into the newly installed Python2.7 directory.

Was getting error: could not delete '/usr/local/lib/python2.7/site-packages/pkg_resources/_vendor/__init__.py': Permission denied even though appeared to be owned by the result of whoami (the only non-root user on the computer).

For what it's worth, there were a bunch of packages that had been stalled as root, which I tried to chown as follows: find /usr/local/lib/python2.7/site-packages -type f -name '*.py*' | sudo tee xargs chown my_user_name. It seemed to have worked on the files, but isn't changing ownership on directories. Possibly using -type d -name '*' would have worked.

foresmac commented Feb 4, 2016

I got this just now on 10.10.5 and trying to brew install python.

copying build/lib/setuptools/__init__.py -> /usr/local/lib/python2.7/site-packages/setuptools
error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/setuptools/__init__.py'
Contributor

DomT4 commented Feb 4, 2016

@foresmac Please open a new issue, Thanks! Want to avoid everyone getting multiple notifications on a 3+ year old thread.

@DomT4 DomT4 locked and limited conversation to collaborators Feb 4, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.