I want Python 3 (and I do not want to mess with OS X provided python). According to:
Homebrew provides formulae to brew Python 3.x and a more up-to-date Python 2.7.x. Important: If you. Python -m pip install --upgrade setuptools. Similarly, pip.
I can get Python 3 and live long and prosper, BUT it is not clear what happens when I want to upgrade using the next DMG. As an example I can tell you what happens with R on OS X: you get a GUI in /Application and stuff in /Library/Frameworks. On upgrade the GUI is upgraded and the new framework is placed in the /Library/Frameworks directory, side by side with the old (there is a nice ‘current’ symlink that makes sure that the old stuff is ignored). I always delete the old stuff to avoid accumulating crud, and that’s it. Would this approach work for Phyton?
user1256923user1256923
3 Answers
I personally use Homebrew, which is a very nice package manager.If you want to give this a try, first of all make sure you have the XCode Command Line Tools installed on your Mac.Then install Homebrew by typing
in the Terminal.Homebrew will place its 'Cellar' (the set of all the packages you installed with Homebrew) in /usr/local/Cellar.
Now, about Python 3, once Homebrew is installed simply type
and there we go. You have Python3 installed on your Mac.
Notes:
- this version will automatically take place instead of the OS X version (if it doesn't, just run
brew link python3
- this will symlink python3 into /usr/local/bin/) - to update python run
brew update
in the Terminal (this will update Homebrew) and thenbrew upgrade python3
if a new version of python3 is found by the commandbrew update
- at the end you can run
brew cleanup python3
to remove every old version - with this fancy package manager, you can also take care of R
AlessioXAlessioX
Use Homebrew :)
Hombrew installs everything into
/usr/local/Cellar
and creates symbolic links for applications in /usr/local/bin
. It will not touch anything else in the system. It comes with the brew cleanup command, which removes unused or outdated applications automatically. To update it:
It will automatically link to the newest version after an upgrade and
brew clean
removes any remains of the previous version.madmax1madmax1
You can use the Anaconda distribution. Its a free version of Python 3 (and Python2). The Andaconda package will also let you update different python versions and upon installation it sets the proper python path. Anaconda comes with Anaconda Navigator which helps you load python packages and comes also with Spyder 3. A Python IDE type of app.
jmhjmh
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged python .
If I download python from the Python website and try to install it with the installer, it installs, but I need to specify that I want the new version of Python when I run my programs from terminal. If I just type:
It runs with the old version.
How do can I set the new version as default?
Philippe MongeauPhilippe Mongeau
3 Answers
I finally found how to do it.The installer made a python 2.6 folder in /ApplicationIn this folder is a script called Update Shell Profile.commandI just needed to execute it and now it's working.
Philippe MongeauPhilippe Mongeau
Two questions:
- Where did the new Python get installed?
- What does your $PATH look like?
A default set-up on Unix-like systems is that user-installed software gets installed in /usr/local/bin, and most *nix distros put that directory before system-wide directories in the default $PATH variable (which is how your shell knows where to look for programs). That way, if you install something new, the new item gets found first.
However, a default OS X $PATH looks like this:
The problem is that by putting /usr/local/bin so late, the system-wide Python (which is at /usr/bin and so earlier in your $PATH) keeps getting hit.
My answer is to make my $PATH look like this on a Mac:
To do that, create a file .profile in your home directory and add something like this:
Edit: I'm following up here, rather than in comments because it's getting too long for a comment. The line in your .profile with
/sw/bin/init.sh
comes from the package manager Fink, which I'm assuming you use (or used at some point). The other line seems to suggest that at some point you installed MacPython and it rewrote your $PATH
for you. I don't know MacPython, but if it's this site, then it hasn't been updated since 2004. It also doesn't seem to talk about any version of OS X beyond 10.3, which is not very current.So now I'm more confused: when did you update Python? How did you update it? What version of OS X are you running?
TelemachusTelemachus
Find out where python lives:
See if it's a symlink:
If so, link /usr/bin/python to the new python:
Check if it works:
Bill WeissBill Weiss