Friday, May 14, 2010

Python development environment on Windows

Download Python msi installer from here. It is recommended to run the installer with administrator privileges. Point your installation directory to program files:
C:\Program Files\Python26
Create a system variable PYTHON_HOME and point it to the python installation directory. Append the following to PATH system variable:
;%PYTHON_HOME%;%PYTHON_HOME%\Scripts
Restart your computer so the environment changes take place.

Setuptools and easy_install

Setuptools available here. Download exe version and launch it. Once installer completes you will have easy_install available in %PYTHON_HOME%\Scripts directory.

MinGW

The easy_install needs C++ compiler in order to compile the C extensions that likely be distributed as source along with the python source. MinGW - is a native Windows port of the GNU Compiler Collection (GCC). You can download it from here. You need to select two options during install:
  • g++ compiler
  • MinGW Make
Point your installation directory to program files:
C:\Program Files\MinGW
Add the following to %PYTHON_HOME%\Lib\distutils\distutils.cfg file:
[build]
compiler=mingw32

Virtualenv

Virtual python environment builder can be installed this way:
easy_install virtualenv
Once you are done you can create isolated environment:
virtualenv --no-site-packages devenv
Please note that you must to run python, easy_install from your environment Scripts directory. You must manually copy %PYTHON_HOME%\Lib\distutils\distutils.cfg file to your environment e.g. devenv\Lib\destutils in order to be able compile C extension in your isolated environment.

No comments :

Post a Comment