Python
Attention: Research Computing Documentation has Moved
https://docs.rc.uab.edu/
https://docs.rc.uab.edu/
Please use the new documentation url https://docs.rc.uab.edu/ for all Research Computing documentation needs.
As a result of this move, we have deprecated use of this wiki for documentation. We are providing read-only access to the content to facilitate migration of bookmarks and to serve as an historical record. All content updates should be made at the new documentation site. The original wiki will not receive further updates.
Thank you,
The Research Computing Team
Python
- EasyInstall (a python module (easy_install)) is bundled with setuptools to automatically download, build, install, and manage Python packages [1].
- To have a complete Python development environment (install plugins, apps, eggs) in your $HOME, python path must be configured properly.
- Default installation of EasyInstall/setuptools would install packages/eggs to the Python’s primary site-packages directory
Customize Python Packages Install Location to $HOME
Mac OS X
- Mac OS X comes with a pre-installation of Python, usually one or two years old [2]. Mac OS 10.6 (Snow Leopard) has 2.6.1 version of Python. This is adequate for developing most Python applications like Trac, Galaxy etc. To install a newer version of Python, [see here].
- The default installation location for Python packages on Mac is /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages.
- Mac has native support for user installation of Python packages i.e., on a Mac OS X machine, you should just use the ~/Library/Python/2.x/site-packages directory as your custom installation location, because it is already configured to process .pth files, and already knows this [3]. If the above directory does not exist in your $HOME, create it.
mkdir -p ~/Library/Python/2.6/site-packages
- Before installing EasyInstall/setuptools, just create a ~/.pydistutils.cfg file with the following contents (or add this to the existing contents):
[install] install_lib = ~/Library/Python/$py_version_short/site-packages install_scripts = ~/bin
- This will tell the distutils and EasyInstall to always install packages in your personal site-packages directory, and scripts to ~/bin. (Note: do not replace $py_version_short with an actual Python version in the configuration file! The distutils will substitute the correct value at runtime, so that the above configuration file should work correctly no matter what Python version you use, now or in the future.)
- Note, however, that ~/bin is not in the default PATH, so you may have to refer to scripts by their full location. You may want to modify your shell startup script (likely .bashrc or .profile) or your ~/.MacOSX/environment.plist to include ~/bin in your PATH.