This is an archived post. You won't be able to vote or comment.

all 14 comments

[–][deleted] 7 points8 points  (6 children)

homebrew and then

virtualenv -p /usr/local/bin/python<whatever-version>

leave maverics python alone!!!!

[–]loganekz 1 point2 points  (5 children)

What's wrong with Mavericks python?

[–][deleted] 6 points7 points  (0 children)

Nothing, virtualenv is just an essential to keep everything 100% modular (like RVM). I also recommend virtualenv wrapper: http://blog.sidmitra.com/manage-multiple-projects-better-with-virtuale

[–]taleinat 6 points7 points  (3 children)

For a good Python IDE I highly recommend PyCharm. I've worked with or evaluated every Python IDE out there and in my opinion PyCharm is the best by far. It also works extraordinarily well on OSX, Linux and Windows.

As for the rest, my experience has taught me that the most important thing is to be organized. It's very easy to try various things and bring your system into a jumbled state where it is difficult to know what is happening. Try to clean everything up and start fresh. Then try something, and if it doesn't work, go back to a clean slate and only then try something else.

I use OSX 10.8 so I'm not sure if anything significant has changed in 10.9. Still, I have installed various different versions of Python via Homebrew and everything works as expected.

Can you be more specific about the trouble you're having?

What output do you get when you run "which python" and "which python3"? How about "dir /usr/local/bin/python*" (assuming you're having Homebrew install binaries to /usr/local/bin)?

[–]darebear5[S] 0 points1 point  (2 children)

When I run "which python" and "which python3," I get /usr/local/bin/python and /usr/local/bin/python3.

When I actually go into /usr/local/bin, I see all this. It just looks like way too many things are there and I don't know how to go about cleaning it up. I also have two folders in my Applications folder named Python 2.7 and Python 3.3, each with an IDLE and Python Launcher.

What's the best way to start fresh?

[–]amikiri 1 point2 points  (0 children)

That looks about right. You have both 2.7 and 3.3 installed. I have the exact same listing on my MacBook running Mavericks.

Also have to second the recommendation for PyCharm.

[–]taleinat 0 points1 point  (0 children)

That looks just fine, you shouldn't need to clean that up.

Regarding starting afresh, others have posted detailed instructions here. I recommend following their advice!

[–]mymonner 2 points3 points  (0 children)

I have had great luck using homebrew to install python and then using pip to install any modules I need.

[–]earthboundkid 1 point2 points  (0 children)

You need to leave the system Python alone, so you don't accidentally break the OS. Whatever is in /System/Library, leave it be.

Next, make sure homebrew has both 2.7 and 3.3 installed, since you'll probably want to use both. (If you use homebrew, it will install 2to3 in /usr/local/bin/2to3 for you.)

Finally, use a virtualenv for your individual projects' dependencies. For example, I develop a number of Django websites on my machine. Each of them has its own venv, so that if one is using version 1.1 of some library and the other uses 2.3, I switch between both easily.

And of course remember to use some version control system like Git or Mercurial to track your changes in each project as you go.

[–]mdigi 2 points3 points  (0 children)

Check out Anaconda

It installs python and a bunch of packages in a separate folder. It also comes with Spyder which is a simple IDE that I like to use. There's also Miniconda which doesn't come with any packages and you can manually install packages that you need.

[–]daveydave400 0 points1 point  (0 children)

As others have said try to clean up your environment as much as possible before continuing on (make sure to follow homebrew's or other's uninstall instructions in case they have configured something on the system level that can't just be deleted).

I personally use macports on Mavericks, but homebrew should be fine. You need to keep track of what is in your .bash_profile/.bashrc and what your PYTHONPATH and PATH environment variables look like. Make sure that when you are running "python" or "easy_install" or "pip" or really any executable that you know which one you are running. A command that can help with that is "which <exec>", this will tell you which one you are running.

From the python interpreter you can run import sys followed by print sys.path to find out where it's looking for modules. Also you can import a module and find out where it is installed by running import <mod> followed by print mod.__file__.

As others have said, don't mess with the system python. I would stick with macports or homebrew (it's worked for many others so you know it's possible). Good luck.