Archive

Archive for February, 2012

Philosophical Probability

February 27th, 2012 No comments

It is fascinating to find this kind of paragraphs in classical probability literature by Laplace:

Nearly all our knowledge is problematical; and in the small number of things which we are able to know with certainty, even in the mathematical sciences themselves, the principal means for ascertaining truth -induction and analogy- are based on probabilities

Philosophers (some call them scientists now), the real predictors of the future.

Categories: science Tags:

Install Python 2.7.x under Snow Leopard / Lion (64 bits)

February 13th, 2012 5 comments

OS X comes with a Python installation that I find a bit confusing and misleading. What I present in this post is a guide to remove the default Python from your 64 bits OS X (i.e. Snow Leopard or Lion), install its latest version, and set up a nice environment to work with (e.g. iPython + MacVim). The only requirement for this process is to have the latest version of XCode, that you can get from the App Store.

Uninstall Python

I couldn’t find any nice and clean uninstaller for Python in OS X. So we will have to remove all files by hand. Here is the code:

sudo rm -rf /Library/Frameworks/Python.framework
sudo rm -rf /Applications/Python*
sudo rm -rf /Library/Python*
cd /usr/local/bin
sudo rm -rf 2to3 idle idle2.7 pydoc pydoc2.7 python* smtpd.py smtpd2.7.py
cd /usr/bin
sudo rm -rf 2to3 idle idle2.7 pydoc pydoc2.7 python* smtpd.py smtpd2.7.py

(if you have another versions of Python installed (e.g. 2.6, 2.5), just change 2.7 for your version number when removing the files. However, that is not really that important, just so that you don’t have that much garbage in your computer).

Install Python 2.7.x

Now let’s install the latest release of 2.7.x for OS X. You can see the latest releases here. When writing this post, the latest version is 2.7.2.

Once you have run the installer, edit your ~/.bash_profile file. To edit your file, use your favorite text edito (vim in my case):

vim ~/.bash_profile

You should now have the following lines (add them if you don’t, but the installer is supposed to add them for you):


# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

Now let’s add the compiler flags for 64-bits and the Python Path for the modules. This is important, otherwise your easy_install will probably fail. Add the following lines to your ~/.bash_profile:

export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
export CFLAGS="-I/Developer/SDKs/MacOSX10.7.sdk/usr/lib/"
export ARCHFLAGS="-arch x86_64"

(note: change MacOSX10.7 to MacOSX10.6 if you’re using Snow Leopard in the second line)

Notice that all your modules will be installed here:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages. It’s kind of important to remember this path, so you may want to add it to your sidebar in Finder or create some soft link.

Close your file and restart your bash so that the new environment variables are available. Check that you can now run python from the new terminal.

Install most common modules

I usually use easy_install to install new modules. You can get it from here (the module is called setuptools).

Download it, decompress it, and type the following from it’s folder:

python setup.py build
python setup.py install

Now you can use easy_install to install your favorite modules. E.g.:

easy_install numpy
easy_install scipy
easy_install matplotlib
easy_install ipython

If you’re running Lion, I highly recommend the SciPy SuperPack, which will do all the work for you.

Setting up your programming environment

This last section is completely biased due to my eternal love to VIM. I know some heartless people who use Emacs, or even Eclipse (I was one of them, and it was a terrible thing!) to code in Python.

If you’re a VIM lover you should already know about MacVim, but if you don’t you should definitively get it.

In any case, you should choose your favorite text editor (in case you want to use VIM -everybody wants to use VIM, but unfortunately some people don’t know that-, here it is a nice python module), and then I highly recommend using iPython instead of the classic Python console. This is especially useful for debugging and plotting. iPython is life changing, really.

To run iPython with matplotlib already running in the background just type:

ipython --pylab

Finally, here is a nice screenshot of how my programming environment looks like (iPython + PyLab + MacVim):

Beautiful isn’t it? : )

And finally, for something -not that- completely different: Happy programming!

Categories: programming, python Tags:
paulospizza.ca/cfd-157137/ Lekht, ilya lenz, heinz-josef lerner, alexander lew, mark f. Stronger painkillers can be prescribed if needed. http://nemionis.com/imk-158665/ Stronger painkillers can be prescribed if needed. The symptoms of these associated conditions often obscure the diagnosis of adenomyosis. Several published guidelines are available for ufe, including those jointly created by the canadian interventional radiology association and the society of obstetricians and gynaecologists of canada. viagra reduced hamster jetlag http://apachesongs.com/sel-156785/ The symptoms of these associated conditions often obscure the diagnosis of adenomyosis. I don't want to have any surgery. Hon. Org uteoine-fibroids. generic viagra website reviews centrogommesrl.it/hue-157346/ The polymer is preferably in particulate form, such as in the form of microspheres. Uterine artery embolization does not have adverse effects on ovarian reserve in regularly cycling women younger than 40 years. Hiti, alan l. fondazionepertini.it/figers/colombian.php?obr=155597 I don't want to have any surgery. Sirweb. viagra paypal payment uk cheap viagra jelly Org uteoine-fibroids. viagra cost 50mg