-1

I am running OS X Version 10.9.4.

I have run brew install python. I get the following errors... Could somebody please explain to me what is happening and what I can do to fix it?

I'm follow this tutorial: http://doc.scrapy.org/en/latest/intro/install.html (Ultimately I am trying to download Scrapy. If anybody has anything that can give me a really detailed step by step apart from their website's tutorial I'd really appreciate it)

=> brew install python
==> Installing python dependency: readline
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/readline-6.3.8.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-6.3.8.mavericks.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X provides similar software, and installing this software in
parallel can cause all kinds of trouble.

OS X provides the BSD libedit library, which shadows libreadline.
er to prevent conflicts when programs look for libreadline we are
ting this GNU Readline installation to keg-only.

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/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
  /usr/local/Cellar/readline/6.3.8: 40 files, 2.1M
==> Installing python
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/python-2.7.8_1.mavericks.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring python-2.7.8_1.mavericks.bottle.2.tar.gz
==> Caveats
Setuptools and Pip have been installed. To update them
  pip install --upgrade setuptools
  pip install --upgrade pip

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python

.app bundles were installed.
Run `brew linkapps` to symlink these to /Applications.
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
  rm /usr/local/bin/2to3

To force the link and overwrite all conflicting files:
  brew link --overwrite python

To list all files that would be deleted:
  brew link --overwrite --dry-run python

Possible conflicting files are:
/usr/local/bin/2to3 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/2to3
/usr/local/bin/2to3-2 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2
/usr/local/bin/2to3-2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7
/usr/local/bin/idle -> /Library/Frameworks/Python.framework/Versions/2.7/bin/idle
/usr/local/bin/idle2 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/idle2
/usr/local/bin/idle2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7
/usr/local/bin/pydoc -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc
/usr/local/bin/pydoc2 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2
/usr/local/bin/pydoc2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7
/usr/local/bin/python -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python-config -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/usr/local/bin/python2 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python2
/usr/local/bin/python2-config -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/usr/local/bin/python2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/usr/local/bin/python2.7-config -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
/usr/local/bin/pythonw -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw
/usr/local/bin/pythonw2 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2
/usr/local/bin/pythonw2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
/usr/local/bin/smtpd.py -> /Library/Frameworks/Python.framework/Versions/2.7/bin/smtpd.py
/usr/local/bin/smtpd2.7.py -> /Library/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.7.py
/usr/local/bin/smtpd2.py -> /Library/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.py
==> /usr/local/Cellar/python/2.7.8_1/bin/python -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.8_1/bin --install-lib=/usr/local/lib/python2.7/site-packa
==> /usr/local/Cellar/python/2.7.8_1/bin/python -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.8_1/bin --install-lib=/usr/local/lib/python2.7/site-packa
==> Summary
  /usr/local/Cellar/python/2.7.8_1: 4776 files, 76M
Ishaan Taylor
  • 1,817
  • 5
  • 17
  • 19
  • Also, why are you doing `brew install python`? You already have Python 2.7.5; it came with Mavericks. Do you need one of the bug fixes in 2.7.8? Or do you just want to learn how to manage two parallel installations of Python 2.7 both on your `PATH` because that sounds like fun? – abarnert Sep 10 '14 at 00:21
  • what about `Error: The 'brew link' step did not complete successfully` – Ishaan Taylor Sep 10 '14 at 00:22
  • Sorry, I didn't realize you'd posted so much that it scrolled down… – abarnert Sep 10 '14 at 00:23
  • @abarnert many sources recommended installing a packaged python rather than relying on the one that comes with mavericks, so perhaps hold your criticism on that front – John Mee Sep 10 '14 at 00:26
  • @JohnMee: Many sources were written for OS X 10.5, which came with a version of Python that was both very old and partially broken. At any rate, if you want to learn how to manage two (or, actually, three) versions of Python 2.7 on your `PATH` in parallel even though it's unnecessary, be my guest. But you're going to have to know how to do basic things like keep track of which `pip` you're running instead of just running any one of the `pip`s you happen to have. – abarnert Sep 10 '14 at 00:31
  • @IshaanTaylor: And meanwhile, your second problem is a completely independent problem, so it should be in a separate question. But if you know you have a failed Python installation, you shouldn't really be trying to solve `pip` problems yet anyway… – abarnert Sep 10 '14 at 00:32
  • Okay. Thanks for your help. I'll come back to this when I figure out the first problem. – Ishaan Taylor Sep 10 '14 at 00:36

1 Answers1

2

Your problem is that you already had a Python 2.7 installed to /usr/local (on top of the Python 2.7 that Apple pre-installed to /usr). The most likely guess is that you ran the official installer from python.org.

Since Homebrew tries to install to /usr/local, and you can't have two things with the same name in the same place, it won't let you do this.

If you really need to have three Python 2.7s on your system, you will have to pick a different location for one of them. Notice that the existing one is actually just a bunch of symlinks to /Library/Frameworks/Python.framework/Versions/2.7/, and the new one you're trying to install is actually just a bunch of symlinks to /usr/local/Cellar/python/2.7.8. So the symlinks aren't really necessary for either one. And Homebrew makes it easy to not install the symlinks: just don't do the link step.

Of course this means that you can't just run pip to install packages for the Homebrew Python, you have to /usr/local/Cellar/python/2.7.8/bin/pip. And of course you also have to run /usr/local/Cellar/python/2.7.8/bin/python to use the Homebrew Python.

Needless to say, you could add the cellar directory to your PATH… but that's going to increase your confusion even more. You can very easily end up with, e.g., the first pip on your PATH being from the Homebrew cellar, while the first ipython is from the python.org install, so you install things but can't find them—or, worse, your pip and your python-config don't match, so every installation than needs the C compiler gets confused and fails.

All of this raises the question of why you need three Python 2.7 versions (at least two of them on your PATH), much less two versions. If you know what you're doing, you can make that work… but that clearly isn't the case here. So, why are you trying to make things hard for yourself?

abarnert
  • 354,177
  • 51
  • 601
  • 671
  • I had to run brew install python because I was installing Crazyflie Client for another project and Apple modified the python build in a way that couldn't work with the client. See http://wiki.bitcraze.se/projects:crazyflie:pc_utils:install?rev=1376354911#installing_on_mac_osx – Ishaan Taylor Sep 10 '14 at 00:35
  • What would you recommend is the best way to fix this problem? – Ishaan Taylor Sep 10 '14 at 00:37
  • @IshaanTaylor: That page doesn't say "Apple modified the python build in a way that couldn't work with the client" anywhere, so where did you get that? Also, what made you think you needed to install _both_ a python.org (or some other) Python _and_ the Homebrew one? – abarnert Sep 10 '14 at 00:38
  • @IshaanTaylor: Meanwhile, the best way to fix the problem is (a) if you don't need either extra Python, get rid of both of them; (b) if you need the Homebrew one but don't need the other third-party one, get rid of that one; (c) if you really need all three, learn more about Unix administration and about how Homebrew works, because you're going to need it. – abarnert Sep 10 '14 at 00:40
  • I was having some problems installing the client so I did some googling to find somebody's post about this, and I followed their advice and it fixed the problem. In that post it described why the issue was occurring. I tried to find the post but I can't seem to recall any keywords from it. I falsely assumed Homebrew would remove an existing installation. I believe keeping the homebrew one is the best way to go from here. Thanks for your help. I'll test this out then give my feedback. – Ishaan Taylor Sep 10 '14 at 00:42
  • can you explain how to safely get rid of the default python? – Ishaan Taylor Sep 10 '14 at 00:48
  • @IshaanTaylor: You don't want to get rid of the default python; if you could, (a) it would break all kinds of stuff, and (b) it would just get reinstalled the next time you upgrade to 10.9.5 or 10.10.0. You can get rid of the other third-party Python, of course, but you'll have to tell us how you installed it before anyone can tell you how to uninstall it safely. (And keep in mind that whatever packages you installed for that Python, you'll need to reinstall.) – abarnert Sep 10 '14 at 01:09
  • I would chat with you but I don't have enough reputation.. I appreciate your time with this issue. I installed python via `brew install python`. Now I've run `brew uninstall python` and tried `sudo easy_install pip` and it's saying `/lib/python2.7/ does not exist`- however `/lib/python/2.7` does exist.. I'm assuming `python2.7` is the default python because most sites use that as its default..but somehow I don't have it or deleted it? Anyways, I went on and downloaded `get-pip.py` and ran `sudo easy_install get-pip.py. This worked. – Ishaan Taylor Sep 10 '14 at 02:35
  • However, for `curl https://bootstrap.pypa.io/ez_setup.py -o - | python`, it again tried to install it in `/lib/python2.7`. It feels as though I'm missing something here.. – Ishaan Taylor Sep 10 '14 at 02:36
  • `python2.7` exists; the problem is that for some reason it's trying to install in `/` instead of in `/usr/`, `/usr/local/`, or `/Library/Frameworks/Python.framework/2.7/` or somewhere else reasonable. When you do `which easy_install`, what version do you get? My guess is that it's from your third Python, and that one is somehow misconfigured. – abarnert Sep 10 '14 at 03:51
  • when I do `which easy_install` I get `/usr/bin/easy_install` – Ishaan Taylor Sep 10 '14 at 03:58
  • `easy_install`, `pip`, the `setuptools` bootstrap, and the `pip` bootstrap (and the stdlib's `distutils`) all look at Python's configuration to figure out where to put things. Unfortunately, IIRC, before 3.x, the `python-config` command line didn't have any way to get the install directory. But from within Python, you can print out `sys.prefix` and `sys.exec_prefix` and see what they say. It's also possible that you've just somehow gotten your site-packages directory itself hosed. – abarnert Sep 10 '14 at 04:13
  • @IshaanTaylor: Meanwhile, have you removed the third Python (the one in /usr/local), so you only have one 2.7? We can try to repair the Apple one (possibly just doing an OS X repair?), or install the Homebrew one and (carefully) use that instead… but if there's another Python you don't even want getting in the way of either or both, that's going to make things harder. – abarnert Sep 10 '14 at 04:14
  • This is the contents of /usr/local- it looks like there is no python `CODEOFCONDUCT.md LICENSE.txt SUPPORTERS.md lib var CONTRIBUTING.md Library bin opt Cellar Qt4.8 etc sbin Frameworks README.md include share` – Ishaan Taylor Sep 10 '14 at 16:08
  • could you please help me figure out how to use the homebrew python with virtualenv? – Ishaan Taylor Sep 23 '14 at 15:20
  • @IshaanTaylor: What are you stuck on? If you've installed `virtualenv` with the Homebrew Python's `pip`, and it's the only Python you've installed it into, just use the normal commands. If you've installed it into two or more Pythons, then you have to use the explicit path instead (or create aliases or symlinks that do it for you), which you can probably find by using `which -a`. If you need more help, you should probably create a new question. – abarnert Sep 23 '14 at 18:18
  • @IshaanTaylor: Meanwhile, `/usr/local` is just a prefix, with `bin` and `lib` and `share` and so on directories. It's not on your PATH; `/usr/local/bin` is on your PATH. So you'd have a `/usr/local/bin/python`, maybe a `/usr/local/lib/python2.7`, etc., not a `/usr/local/python`. (However, in most cases, Python is installed into a framework in `/Library/Frameworks`, or `/System/Library/Frameworks` for the Apple pre-installed one, or a `Library` directory in a `/usr/local/Cellar` subdirectory for a Homebrew one, and only symlinks get put into `/usr/local` in the first place.) – abarnert Sep 23 '14 at 18:20
  • @abartnert I am using homebrew's python. please see this post for a full description of the problem I am facing: http://stackoverflow.com/questions/25816674/update-pip-is-not-able-to-install-packages-correctly-permission-denied-er – Ishaan Taylor Sep 23 '14 at 20:25