Ann: Activepython 2.4.1 For Mac
1.2.3 Mac OS For those using a MAC-OS, IVEware can be used only as stand-alone or with Stata, R and SPSS. To install on a Mac, download the file “srcwaremacosx64.tgz” from www.iveware.org and extract “Srcware.app” into an appropriate parent directory, say, /Applications/, or the home directory. You can choose any location.
Python for Astrostatistics - Mac OS X Installation Python for Astrostatistics - Mac OS X Installation Note: You need to know the adminstrator/root password to install what you need. This is the same password OS X asks you for whenever you install or update a significant system component. The 'sudo' command, invoked many times below, will produce a prompt asking you for it. This guide also presumes you are comfortable with use of the OS X Terminal application; these commands should be entered at a shell prompt in a Terminal window.
See the page if you'd like to learn more about this software before or after installation. Install Python for OS X OS X comes with a version of Python already installed. However, it is a rather minimalist installation, and it typically lags the current version by one minor version number (e.g, 2.3 vs.
You should install a separate version that is more recent and more feature-filled. It will not overwrite Apple's version, but it will be installed as the first 'python' on your command path, so you will never encounter Apple's Python unless you go out of your way to use it. I recommend two options; I have installed the software mentioned below with both of them:. MacPython Mac Python developer Bob Ippolito hosts of this version of Python for both OS 10.3 and 10.4. The current version is 2.4.1, one 'microversion' behind the current Python.org release. Microversions are bug-fix releases; in six years of Python programming I have yet to encounter a bug, so the minor version lag should not concern you.
ActivePython The 'new kid on the block,' is a binary installer that largely duplicates the MacPython installation (with the notable exception of omitting 'readline' command line editing support due to license issues). But it includes a few extras, including an array of documentation (accessible via the 'Library' menu in Help Viewer; you may need to logout and login again for the docs to get registered). It is maintained by ActiveState, a commercial developer tools company, but is provided for free.
It is up-to-date with Python.org, at 2.4.2. You will really want readline capability (giving you cursor-based editing at the command prompt). The only way to get it is to grab an appropriate pre-built library from somewhere. Use the appropriate version to replace ActivePython's empty stub in this directory: /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload/ I can't guarantee this will work, but several users have reported success with this procedure.
You will know it's working if, after starting the interactive Python interpreter with 'python', you can use your arrow keys to edit an expression typed at the ' Python prompt. A quirk of OS X is that its window manager works quite differently than that of other platforms. As a result, if you run a Python program that requires GUI interaction (e.g., anything that plots with matplotlib), you should run it with the GUI-enabled 'pythonw' command rather than 'python'. (ipython, installed below, always uses pythonw on the Mac.) The pythonw command is one of the 'extras' you get with the Python distributions above (vs. Apple's Python, which has no cross-platform GUI support). 'python' and 'pythonw' get installed in /usr/local/bin; make sure this is earlier than /usr/bin (the location of Apple's Python) in your shell's PATH variable. There are a few other Python-based applications that get installed that you will want to access from the command line (e.g., idle, Python's IDE, and f2py, a Fortran-Python interface tool).
To get easy access to these, you need to add the location of your new Python's binary directory to PATH. For example, the beginning of my PATH (from 'echo $PATH' at the shell) is: /usr/local/bin:/System/Library/Frameworks/Python.framework/Versions/Current/bin. That second, long path is where MacPython and ActivePython install their binaries. Edit your.cshrc file (for tcsh shell) or.bashrc (for bash shell) to adjust your PATH accordingly. Prepare for Package Installation You will need to be able to install Python packages from source; that is, you will run (simple!) commands that compile C, C, and Fortran source code.
You will also need some libraries the code must link against. You need to have Apple's Developer Tools installed to get gcc. A DVD with the Tools comes with OS X releases; the tools are also available as a free (but large!) download from (you'll need to create a free account, then go to the download area and find the tools for your OS version). You also need (Tiger users may have it already installed).
Finally, you need an OS X version of the g77 Fortran compiler. Optionally, consider installing the FFTW2 Fourier transform library to accelerate FFTs. Chris Fonnesbeck's page explains where to get g77 and FFTW2. The gcc compiler used by Apple's Developer Tools recently underwent a major version change, from 3.x to 4.x. For OS 10.4, the default gcc is a 4.x version.
Users of a wide variety of software have reported problems due to bugs in early 4.x releases. The safest course is to change the default gcc to 3.x. Use 'gccselect -l' to list available compiler versions. Then use 'gccselect #.#' to set the active gcc compiler to version #.# (you may need administrator privileges to perform this operation; i.e., prefix it with 'sudo'). Version 3.3 should be available and should work fine. Reportedly, very recent gcc-4.x versions are relatively bug-free, and you may have success with them (check Apple Developer Connection for the latest version).
Further tips on this are at Chris's web page. You have been forewarned. The matplotlib plotting package requires the (v.
2.1.7 or later), and libraries. Panther users in particular will not have all of these unless they have been installed separately; I'm not sure of the situation for Tiger.
Perhaps the most-used way to get them is as pre-built binaries via a package manager like. (Here are some specifically to get these libraries.) If you are using the popular, then you can use the i-Installer application you used to install TeX to install Freetype and perhaps the other libraries (use the i-Installer to see what's currently available). The libraries also build fine from source, using the standard './configure -prefix=/usr/local; make; make install' installation sequence with minor variations. The gives instructions for libpng; describes the procedure for FreeType and libpng.
Also, recently libpng was made available as an OS X binary from the libpng page linked above. I personally have used FreeType via i-Installer and the other libraries built from source. You will soon be editing files containing Python source code. It will be handy to use an editor with a Python mode.
There are many choices; some that I use on the Mac are xemacs (in an X11 xterm), with its plugin (huge but feature-filled; good for organizing multi-file projects), and (a very popular commercial text editor). If you are an emacs/xemacs fan, there is a useful Python mode for emacs.
The IPython page hosts a widely-used, self-contained version:. You may also consider a newer, multi-file version that offers more functionality, just released by the.
Install Packages for Scientific Computing For several packages, you should be using a recent developer snapshot from the developer SVN or CVS archive, rather than the last official release, due to many recent innovations and bugfixes. At this point, OS 10.4 (Tiger) users are in luck.
Chris hosts binary installers for the largest and most important packages we need. Install the numpy, scipy, numarray, and matplotlib packages from (simple instructions are there). Then pick up the installation process below at 'ipython-0.7.0'. But read the comments at the end of the 'scipy' entry, about suppressing import overwrite warning messages, and a recent FFT bug.
For OS 10.3 (Panther) users like myself, binaries may be available within a few days. But in light of the uncertainty, I've packaged all the releases in a so you can build the packages from source (time-consuming, but simple; and it's the computer that will take all the time). Download it and unpack it ('tar zxf samsi-dist.tar.gz') somewhere on your hard drive where you have substantial free space (300 MB or so). This will create a directory 'samsi-dist' containing all the software. Then, in the following order, in a Terminal window, 'cd' into the following directories and run the following install commands. The numbers in brackets indicate the minutes:seconds the command took on my old and slow 333 MHz PowerBook G3, to give you some idea of what to expect.
Commands with no brackets run very quickly. You may delete each directory after the installation if you'd like to free the space (if you keep them, you can update the contents later via SVN or CVS and rebuild). You can safely ignore the many innocuous compiler warnings that will appear during some install procedures (they're warnings, not errors; real errors will abort the install process). The installations end with little fanfare; if there are no failure messages, the install went just fine. If you have trouble with the installation, you can ask for help on one of the following email support lists. Please contact me for help only as a last resort, or if you think there is a mistake in these instructions; I will be in very limited email contact until the CASt/SAMSI School is over. Discussion of Python on the Mac.
Members have provided help for many of the packages here, and especially for general Python issues on OS X. For help with numpy and scipy. For help with matplotlib. (see the section near the bottom of this page) A community of astronomers who use Python, including the developers of numarray, PyFITS, and numdisplay. Some packages come with test suites that you can run to verify the installation.
I describe some below. I recommend you keep a separate shell open in which to run the tests. This will ensure that Python is finding the package installed in its global site-packages directory, and not in the distribution directory. Now to the package installations, by directory name under the unpacked distribution: numpy sudo python setup.py install 5:28 If you'd like to verify the installation, try this in your home directory (' is the Python prompt; hit Ctl-D to quit Python at the end): python import numpy numpy.version '0.9.3.1882' numpy.test(1,1) It will print out a lot of information, including several lines of periods. Indicates a passed test; failures will produce obvious and verbose messages. There may be a few warnings, errors or failures among the 200 tests (they are being sorted out and won't affect our basic use).
On my Mac all tests pass with this numpy release. Scipy sudo python setup.py install 43:51 Test with: python import scipy scipy.version '0.4.4.1544' scipy.test For a lengthier suite of tests, you may also try 'scipy.test(10)'. Around 1000 tests will be run; as above you can ignore the small number of possible failures for now (I get about 10). A few users have encountered a linking error when the installer attempts to build fftpack. If this happens, consult for a workaround. When you import scipy, it imports numpy. Both packages have FFT functions, so you will see a warning that SciPy is 'overwriting' NumPy's fft and ifft functions.
Ann Activepython 2.4.1 For Mac
You can disregard this. If you'd like to suppress this import warning, set the SCIPYIMPORTVERBOSE environment variable to '-1' in your shell. For tcsh, use 'setenv SCIPYIMPORTVERBOSE -1' and for bash, use 'export SCIPYIMPORTVERBOSE=-1'. You can use these at the command line, or stick them in your.cshrc or.bashrc file to make them 'permanent.'
One last quirk. Recent revisions introduced a bug with SciPy's FFTs in at least some OS X installations; NumPy's FFTs remains solid. This will get sorted out soon; in the meantime, use numpy.fft and numpy.ifft in place of scipy.fft and scipy.ifft. Numarray-1.5.0 sudo python setup.py install -gencode 10:16 Test with: python import numarray.testall as testall testall.test matplotlib-0.86 sudo python setup.py build 33:18 sudo python setup.py install 0:55 Test it by going into the 'examples' directory and trying to plot one of the examples. Since matplotlib displays plots in a GUI window, you need to use 'pythonw' to run the examples in OS X. Try: cd examples pythonw filldemo.py In the course of making your first plot, matplotlib will create a '.matplotlib' directory in your home directory where it can access a startup profile and cache various information.
You will likely see a bunch of warnings referring to obscure fonts it cannot find as it tries to build a font cache; you can safely ignore these! You should soon see a plot; when you close it, the Python command will terminate. At this point, return to the install directory, where you'll find a default startup profile, 'matplotlibrc'. Copy this to your.matplotlib directory: cd.
Cp matplotlibrc /.matplotlib Use your favorite text editor to edit the copy in your.matplotlib directory (not the original!). About 30 lines down from the top you should find two lines that look like this: backend: TkAgg numerix: numpy # numpy, Numeric or numarray Make sure they say ': TkAgg' and ': numpy' as shown above. These tell matplotlib to use an anti-aliasing Tcl/Tk backend for plotting, and to use numpy arrays. Ipython-0.7.0 Since we'll be using ipython to draw plots with matplotlib, we need to build it with 'pythonw' rather than 'python'; this signals the installer to build a GUI-capable version. The ipython program is a Python script; tell the installer to put the script in /usr/local/bin so your shell will know where to find it. The first time you run IPython (just type 'ipython' at the shell), it will create a '.ipython' directory in your home directory (and warn you about it). It installs a set of default startup profiles there that you may edit to customize how IPython behaves.
Sudo python setup.py install One of IPython's profiles is intended for use with SciPy and is invoked with 'ipython -p scipy'. However, it tries do some 'magic' tailored to the last official release and won't work with the latest version.
So just use plain 'ipython' for now, or write your own profile that automatically imports scipy. PyFITS sudo python setup.py install If you'd like to work through the STScI Data Analysis With Python Tutorial, you should also install the DS9 image viewer (binaries for all major platforms are at the ) and the following Python package from STScI, included in the tarball: numdisplay sudo python setup.py install SAMSI extras Finally, copy the 'samsi-for-home.tar.gz' file to your home directory and unpack it there. It will create a 'samsi' directory that includes a copy of the matplotlib examples directory (a good source of plotting recipes), and copies of some basic documentation: the official Python Tutorial and Standard Library docs, the IPython manual, the matplotlib tutorial, and the STScI Python Data Analysis Tutorial. Maintenance The numpy, scipy, and numarray installations are from current SVN or CVS developer archive revisions. There will be solid official releases of all of these packages quite soon, including binary installers for several platforms; check the web sites (linked on the page) for news about official releases. If you are ambitious (courageous?) and wish to stay on the 'bleeding edge,' do not delete the unpacked directories after installing the software.
As you wish, update them via SVN or CVS as follows (execute these in your shell in the directory right above the package directory), and re-install the packages. NOTE: Before you reinstall a developer snapshot, which may have significant internal reorganization, you should manually remove all results of an earlier installation. To do this, delete the 'build' folder within the package's source directory (the installer creates this to store files during the installation process). Also, delete the installed Python package in your Python's 'site-packages' directory.
ActivePython 2.4.1 build 247 for Mac OS X is now available for free download from: This release includes important updates to build 246. In particular: - ActivePython and py2app will now play nicely together. Previously py2app failed looking for version.plist in ActivePython's framework install. ActivePython's license was clarified to specify that usage of ActivePython with wrapping tools such as py2app and py2exe are allowed. Please see the release notes for details: What is ActivePython? - ActivePython is ActiveState's quality-assured binary distribution of Python.
Builds for Linux, Mac OS X, Solaris and Windows are made freely available. ActivePython includes the Python core and core extensions (zlib 1.2.1, bzip2 1.0.2, bsddb 4.2.52, Tk 8.4.9, and Tix 8.1.4) and is fully compatible with other Python distributions of the same version. ActivePython also includes a wealth of Python documentation, including: - the core Python docs; - Andrew Kuchling's 'What's New in Python' series; - the Non-Programmer's Tutorial for Python; - Mark Pilgrim's excellent 'Dive into Python'; and - a snapshot of the Python FAQs, HOWTOs and PEPs. An online version of the docs can be found here: Thanks, and enjoy!
Trent, Python Tech Lead. Andrea valle Hi to all, it's a bit strange since it's some years I use python but actually I've never used external packages. So I'm a total newbie on the subject. Now I want to install pyx (but it seems that I am not able to. This is my command line: Last login: Thu Jan 1 01:00:39 on console Welcome to Darwin! Apples-Computer: apple$ python /Users/apple/Desktop/PyX-0.8.1/setup.py install running install error: $MACOSXDEPLOYMENTTARGET mismatch: now ' but '10.3' during at Sep 16, 2005 at 11:12 pm. Hi to all, it's a bit strange since it's some years I use python but actually I've never used external packages.
So I'm a total newbie on the subject. Now I want to install pyx (but it seems that I am not able to. This is my command line: Last login: Thu Jan 1 01:00:39 on console Welcome to Darwin! Apples-Computer: apple$ python /Users/apple/Desktop/PyX-0.8.1/setup.py install running install error: $MACOSXDEPLOYMENTTARGET mismatch: now ' but '10.3' during configure apples-Computer: apple$ What's the problem? What should I do? Thanks a lot -a- pS: I've macosx 10.3.8 with active Python 2.4 (#1, Jun 12 2005, 14:30:47). Chris Barker I'm not sure I can be that much help, but I can think of a couple things to try first; Are you sure you're getting active Python with 'python' at the command line?
Depending on how your PATH is configured, you may not be. Perhaps the package you downloaded has some cruft left over from a build on the developer's machine. Try: python setup.py build (you should do that anyway, I always build first, as a user, and then install with sudo) If that gets the same error, you might try deleting the. Andrea valle wrote: Now I want to install pyx (but it seems that I am not able to. This is my command line: apples-Computer: apple$ python /Users/apple/Desktop/PyX-0.8.1/setup.py install running install error: $MACOSXDEPLOYMENTTARGET mismatch: now ' but '10.3' during configure apples-Computer: apple$ What's the problem?
What should I do? PS: I've macosx 10.3.8 with active Python 2.4 (#1, Jun 12 2005, 14:30:47)I'm not sure I can be that much help, but I can think of a couple things to try first; Are you sure you're getting active Python with 'python' at the command line? Depending on how your PATH is configured, you may not be. Perhaps the package you downloaded has some cruft left over from a build on the developer's machine. Try: python setup.py build (you should do that anyway, I always build first, as a user, and then install with sudo) If that gets the same error, you might try deleting the build directory, if there is one, and trying again. It's the easiest way to force a complete rebuild. Andrea valle (Thanks for your help) Yes 2.4 is only active state.
I will try your suggestions. In any case, I tested with python2.3 (macpython) apples-Computer: apple$ python2.3 /Users/apple/Desktop/PyRTF-0.45/setup.py install running install running build running buildpy error: package directory './PyRTF' does not exist the same with: apples-Computer: apple$ python2.3 /Users/apple/Desktop/PyX-0.8.1/setup.py install running install running build running buildpy error: package directory 'pyx' does not at Sep 18, 2005 at 12:57 pm.
Are you sure you're getting active Python with 'python' at the command line?Yes 2.4 is only active state. I will try your suggestions. In any case, I tested with python2.3 (macpython) apples-Computer: apple$ python2.3 /Users/apple/Desktop/PyRTF-0.45/setup.py install running install running build running buildpy error: package directory './PyRTF' does not exist the same with: apples-Computer: apple$ python2.3 /Users/apple/Desktop/PyX-0.8.1/setup.py install running install running build running buildpy error: package directory 'pyx' does not exist There's no more errors of mismatching but there's another one (which seems to be systematic too). Can anyone tell me how to solve this? Should I place installation folder in specific places, I left thoem on desktop? -a- Andrea Valle Laboratorio multimediale 'G. Quazza' Facolt?
Di Scienze della Formazione Universit? Degli Studi di Torino andrea.valle at unito.it. Ronald Oussoren That's odd. You shouldn't get this error message. The error message tell you that the environment variable MACOSXDEPLOYMENTTARGET is present and has a value that is different from the time that Python was build. However, when the current value is the empty string (what the error message seems to suggest) python should just use the value that was used when python was build. What happens when you do this in the shell: $ cd /Users/apple/Desktop/PyX-0.8.1 $ MACOSXDEPLOYMENTTARGET= python.
On 17-sep-2005, at 1:12, andrea valle wrote: Hi to all, it's a bit strange since it's some years I use python but actually I've never used external packages. So I'm a total newbie on the subject. Now I want to install pyx (but it seems that I am not able to. This is my command line: Last login: Thu Jan 1 01:00:39 on console Welcome to Darwin! Apples-Computer: apple$ python /Users/apple/Desktop/PyX-0.8.1/ setup.py install running install error: $MACOSXDEPLOYMENTTARGET mismatch: now ' but '10.3' during configure apples-Computer: apple$ What's the problem? What should I do?That's odd.
You shouldn't get this error message. The error message tell you that the environment variable MACOSXDEPLOYMENTTARGET is present and has a value that is different from the time that Python was build. However, when the current value is the empty string (what the error message seems to suggest) python should just use the value that was used when python was build. What happens when you do this in the shell: $ cd /Users/apple/Desktop/PyX-0.8.1 $ MACOSXDEPLOYMENTTARGET= python setup.py install And what is the output of: python -c 'import os; print repr(os.getenv ('MACOSXDEPLOYMENTTARGET', '))' Ronald.
Andrea valle (thanks) I tried both suggestions. Seems to change nothing. Here you have bash: 1. Last login: Sun Sep 18 14:44:18 on ttyp1 Welcome to Darwin! Apples-Computer: apple$ cd /Users/apple/Desktop/PyX-0.8.1 apples-Computer:/Desktop/PyX-0.8.1 apple$ MACOSXDEPLOYMENTTARGET= python setup.py install running install error: $MACOSXDEPLOYMENTTARGET mismatch: now ' but '10.3' during configure apples-Computer:/Desktop/PyX-0.8.1 apple$ 2. Apples-Computer: apple$ python -c 'import os; print at Sep 18, 2005 at 10:05 pm.