python fails to install on Lion #11594

Closed
Mithoran opened this Issue Apr 12, 2012 · 21 comments

Projects

None yet

5 participants

@Mithoran

brew install python gets through most of the build process, but dies when the newly brew'd python is told to run setup, citing a missing 'time' module. The relevant portion is quoted below, full text in the gist here [ https://gist.github.com/2364629 ]

==> /usr/local/Cellar/python/2.7.3/bin/python setup.py install
/usr/local/Cellar/python/2.7.3/bin/python setup.py install
Traceback (most recent call last):
File "setup.py", line 38, in
exec(open(init_path).read(), d)
File "", line 8, in
File "/private/tmp/homebrew-UNKNOWN-0.6.26-xNNu/distribute-0.6.26/setuptools/init.py", line 2, in
from setuptools.extension import Extension, Library
File "/private/tmp/homebrew-UNKNOWN-0.6.26-xNNu/distribute-0.6.26/setuptools/extension.py", line 5, in
from setuptools.dist import get_unpatched
File "/private/tmp/homebrew-__UNKNOWN_
-0.6.26-xNNu/distribute-0.6.26/setuptools/dist.py", line 6, in
from setuptools.command.install import install
File "/private/tmp/homebrew-UNKNOWN-0.6.26-xNNu/distribute-0.6.26/setuptools/command/init.py", line 8, in
from setuptools.command import install_scripts
File "/private/tmp/homebrew-UNKNOWN-0.6.26-xNNu/distribute-0.6.26/setuptools/command/install_scripts.py", line 3, in
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/private/tmp/homebrew-UNKNOWN-0.6.26-xNNu/distribute-0.6.26/pkg_resources.py", line 16, in
import sys, os, zipimport, time, re, imp, types
ImportError: No module named time

brew doctor output includes the following:
Warning: "config" scripts exist outside your system or Homebrew directories...
....
/opt/local/bin/ncurses5-config
/opt/local/bin/ncursesw5-config

@Mithoran

Retested on Homebrew 11e6add, same error.

@Mithoran

This machine has never had Macports installed; is there something specific that I should be removing / reconsidering that might be preventing the build?

I'm also not sure why ncurses is lingering in /opt/local, but I cleaned it and any other junk out of the directory (/opt/X11/ remains, courtesy of XQuartz). I also verified I'm running XCode 4.3.2. The problem remains.

@Mithoran

Cleaned up the ncurses garbage, brew doctor is now clean ("Your system is raring to brew.").

brew --config and set output (as a comment) - https://gist.github.com/2371696

Not a clue why it's trying to write to ~/Library/.

@Mithoran

rm -rf ~/Library/Python, same error. Switched to bash, same error.

I ran a quick locate looking for other site-package locations, and it looks like the last time I tried to have brew install python, it left behind an empty folder, /usr/local/lib/python2.7. Removing that also didn't solve the issue.

Incidentally, I should note that when I fire up the built-in python (/usr/bin/python, 2.7.1) interactively, it doesn't throw the same error when I import the time module.

@fatlazycat

Sure, if i can do anything to help diagnose let me know. Cheers.

@fatlazycat

no difference, same error.

@fatlazycat

no difference, same error.

@fatlazycat

is there any easy way to run the previous install for 2.7.2 to see if the issue comes from this or just now some env issue ?

@Mithoran

git checkout 97c6869 /usr/local/Library/Formula/python.rb
Run that in /usr/local (just don't commit it), then
brew install python

Tried that, got the same error.

@fatlazycat

I fixed my issue 11616, see the other issue - maybe of some help.

@Mithoran

Same error.

Stuck all those outputs together, search for the command to find the output you want. https://gist.github.com/2388203

@Mithoran

Incidentally, the same error plagues installing python3; setup.py fails, unable to locate the 'time' module.

@Mithoran

Attempted a complete reinstall of brew including its caches, and deleting /usr/local entirely. Same error persists, with python being the first thing I installed after git itself.

@Mithoran

Bump? I have no idea what files beyond those I've already tried clearing out are actually installed/checked by the python install. What other configuration could it be?

@khinsen

I just did my first homebrew installation, under MacOS X 10.7.4, and I had no problem whatsoever with Python.

Something you could check: Run "/usr/local/Cellar/python/2.7.3/bin/python -v", ignoring the tons of output, then type "import time". Does this fail? If not, which path does it show for time.so?

@khinsen

BWT, did you try "brew install python --framework" ? That's what I did.

@samueljohn

--framework should fix this. I think I get the same error and have not yet found a solution.

@samueljohn

I don't know why exactly but installing python (only without --framework) seems to pick up some parts of the system python library or at least some things from python-config or whatever.

I also get an error that says distutils cannot write to a given folder. That can be tracked down to detecting the wrong setuptools installation:

brew install python
[...]
Setuptools installation detected at /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
[...]

Besides that, @Mithoran do you have a .pydistutils.cfg in your home?

@samueljohn

From the https://gist.github.com/2364629, I would say it was attempting to install the .so files into your home and later they are not found. As said before: a .pydistutils.cfg can cause this or did you
Look at this line for example:
copying build/lib.macosx-10.4-x86_64-2.7/_AE.so -> /Users/cetucker/Library/Python/2.7/site-packages

What's the status @Mithoran @fatlazycat ?

@Mithoran

@khinsen The failed install deletes that directory, so I can't run the command you suggest. The python install itself fails (see the gist from above). I've tried the framework install as well, and it fails in the same spot with the same error.

@samueljohn Yes, it turns out I do have such a file (no idea where it came from). It contains the following:

[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin

Moving that file and installing python seems to have succeeded! I think that solves my problem - there was something bogus about the .pydistutils.cfg file, left over from who-knows-what. Thanks so much for the help, folks.

@Mithoran Mithoran closed this Jun 2, 2012
@Mithoran Mithoran reopened this Jun 2, 2012
@adamv

Closing this as a duplicate of the newer pull request.

@adamv adamv closed this Jun 11, 2012
@xu-cheng xu-cheng locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.