What is the best way to install python 2 on OS X?

My colleague wants to use my python 2 code on his OS X machine (10.6). My code imports several built-in python packages, including Tkinter and shelve, and also uses third-party packages including numpy, scipy, matplotlib and ipython.

I ran into some problems with the OS X built-in python. (IDLE does not work, for example *). I suspect that I should install a newer version of python and a different version of Tk .

My questions:

  • Will there be two different versions of python / Tk on the same computer problem?

  • I would like to associate the terminal commands "python", "ipython" and "easy_install" with a newer version of python. How should I do it?

  • When I install third-party packages such as numpy using a .dmg file , how do I control which version of python numpy installs in?

  • Is there a better way to do this?

If this process is going well, I would consider adding OS X instructions to my code documentation, so I would like to reduce this process to the simplest, most general approach.

* EDIT: Also, this

EDIT: . MacPorts, , , , . Xcode . ( ). , ! Xcode , MacPorts . Python python, , , , . , ? MacPorts . , , "Python Launcher" , - python.

, , . , .

+3
6

MacPorts, python 2.6, 2.7, 3.1 3.2 , .

numpy, scipy, matplotlib ipython python.

, python_select, :

  • , ( ) "python" ,

  • python easy_install/pip "" , .

virtualenv , Python.

:

Q1: MacPorts, no. , matplotlib 2.6 2.7, python_select.

Q2: easy_install, pip, ipython "" , . ( . 1)

Q3: py {26,27, xx} -numpy pip install numpy python_select.

Q4: , MacPorts - , APT Debian/Ubuntu...: -)

, MacPorts, :

  • MacPorts OS X, /opt/local, python /opt/local/Library/Frameworks/Python.framework/Versions/{2.5,2.6,2.7,...}. python_select, "python" . ... Versions/{2.5,2.6,2.7,...}/bin, python, PATH. : export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH ~/.profile , .

  • , echo Selected python is \"$(python_select -s)\" ~/.profile, , ...: -)

,

+2

brew //.

python, :

brew install python

Python $PATH ~/.profile:

export PATH=`brew --prefix python`/bin:$PATH

pip, virtualenv virtualenvwrapper, .

+9

ActivePython?

(PyPM), (: ~/Library/Python/2.7). /usr/local/bin; pythonselect, Python.

.dmg, PyPM - ... Python, NumPy .

ActivePython Apple Tcl/Tk , , ActiveTcl.

A < , " :

  • ActivePython 2.7
  • pypm-2.7 install matplotlib ipython
+5

http://python.org/. . DMG , python setup.py install, , setuptools. , .pydistutils.cfg, python install_lib = ~/Library/Python/$py_version_short/site-packages

+2

, .

, python . , .

>> which python 

... , python. Mac OS X "/usr/bin/python"

python MacPorts. . (. )

+1

4 python MacBook Pro. 2 OS X 10.6 , python 2.7 3.2. python, . .

I'm not sure what will happen when you install from a .dmg file. I believe that he will just use any version python.

This superuser.com post answers your questions about changing the default paths.

-1
source

All Articles