Python is a dynamic, interactive, object oriented languages with functional and procedural capabilities. It is well known and documented elsewhere. Also, it is a lot of fun.
In short, it is a general purpose programming language that can be used for scripting, desktop applications, web applications, and more (just about anything except device drivers and the like). It is easy to learn and simple to use. I document here a few things I’ve learned that make Python easier to work with.
Use distribute (which provides the easy_install command) and pip to install packages. Sometimes you may also need to download packages directly from the developers and follow the directions (usually extract, then ‘python setup.py install’). Pip and easy_install are two different commands that go about downloading and installing packages for you from the package index. While easy_install seems more ubiquitous, you may like pip more and sometimes there are packages it handles better.
It’s a good idea to organize your packages per project or experiment, or at least keep from installing packages into the system site-packages directory. The best tool available for this purpose is a package called virtualenv. I recommend installing distribute, pip, and virtualenv into your system wide site-packages directory, then using a virtualenv to organize additional installations.
For Linux users, there may be system packages (RPMs, Debs, etc) for distribute, pip, and virtualenv. Distribute may be listed as setuptools, since it is a fork/replacement for that package. As long as the versions are not ancient they probably will work fine.
If you are on Windows or Mac (or an OS lacking usable packages), download and install the three from their Python sources. If you don’t have administrative rights and permissions needed for the installation and have a recent enough version of Python, you can perform a user installation.
These instructions describe installing distribute, pip, and virtualenv to the system wide site-packages directory.
cd Downloads\distribute-a.b.c
c:\Python27\python.exe setup.py install
cd ..\pip-l.m.n
c:\Python27\python.exe setup.py install
cd ..\virtualenv-x.y.z
c:\Python27\python.exe setup.py install
cd %HOMEDRIVE%%HOMEPATH%
mkdir virtualenvs
cd virtualenvs
c:\Python27\Scripts\virtualenv.exe MyVirtEnv
cd MyVirtEnv
Scripts\activate.bat
c:\Python27\Scripts\virtualenv.exe --no-site-packages MyVirtEnv
cd Downloads
tar zxf distribute-a.b.c.tar.gz
tar zxf pip-l.m.n.tar.gz
tar zxf virtualenv-x.y.z.tar.gz
cd distribute-a.b.c
python setup.py install
cd ..\pip-l.m.n
python setup.py install
cd ..\virtualenv-x.y.z
python setup.py install
cd
mkdir virtualenvs
virtualenv MyVirtEnv
cd MyVirtEnv
source bin/activate
virtualenv --no-site-packages MyVirtEnv
In the above instructions distribute, pip, and virtualenv are installed to the system wide site-packages directory. If you do not have permission to install packages there, you can instead install them into your user account directory.
When you come to the steps involving c:\Python27\python.exe setup.py install on Windows or python setup.py install on other platforms, simply add the --user option to setup.py:
c:\Python27\python.exe setup.py install --user
python setup.py install --user
Take note in the output where these files are going. The executable scripts should land in $HOME/.local/bin on UNIX style systems and in %HOMEDRIVE%%HOMEPATH%\AppData\Roaming\Python\Scripts on Windows. You can then run virtualenv from these paths to get set up.
%HOMEDRIVE%%HOMEPATH%\AppData\Roaming\Python\Scripts\virtualenv.exe MyVirtEnv
~/.local/bin/virtualenv MyVirtualEnv
For completeness sake, it should be mentioned that it is also possible to use another file to control package installation per user. On UNIX like systems this file is $HOME/.pydistutils.cfg and on Windows it is %HOMEDRIVE%%HOMEPATH%\pydistutils.cfg. Use of a pydistutils.cfg should generally be discouraged in favor of the --user and virtualenv methods explained above. You should especially note that using both virtualenv and pydistutils.cfg will not work!
Nevertheless, here is an example of its setup and use on Mac OS X.
The commands below download and install distribute_setup.py, creates the file ~/.pydistutils.cfg (that is, $HOME/.pydistutils.cfg), then installs pip. This will put everything installed by easy_install and pip in your home directory for easy management (and by management I mean wiping out and starting over usually).
# On Mac OS X this would be pasted into the Terminal
echo "[install]" > ~/.pydistutils.cfg
echo "install_lib = ~/Library/Python/\$py_version_short/site-packages" >> ~/.pydistutils.cfg
echo "install_scripts = ~/bin" >> ~/.pydistutils.cfg
mkdir -p ~/Library/Python/2.6/site-packages
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
rm distribute_setup.py
~/bin/easy_install pip
With this file in place, additional packages installed with easy_install, pip, or setup.py install will go into the user’s home directory.