Setting up a Python IDE in Windows
Posted: August 20th, 2009 | Tags: eclipse, python | 1 Comment »Despite there not being that much documentation on it, you can successfully and productively develop Python in an Windows environment. You’ll lose some functionality – notably the excellent virtualenvwrapper isn’t ported – but enough to get by and be good is doable.
Here’s how I set up my working environment, from scratch:
- Install Python using the version of your choice into a directory that doesn’t contain spaces – for example,
C:\Python25 - Install Eclipse, using whatever the most recent version is that’s listed as compatible with PyDev, as well as any extensions that you consider essential (like Subclipse)
- Install PyDev, as described here
- Set up an environment batch file (like I wrote about here) to get your
PATHsset right, and continue these steps from within that command shell - Use
ez_setup.pyto installsetuptoolswithÂ$ python ez_setup.py - Install the Python
win32apiextensions - Install
virtualenvwith$ easy_install virtualenv
At this point, your development environment is set up. With that in place, here’s a workflow for starting a new Python application from scratch:
- Open up a command shell using the batch file you set up earlier in #4
- Change to the directory that you will use to hold your projects – for example,
C:\proj - Create a
virtualenvfor your project with$ virtualenv myproj - Open Eclipse, and switch to a new workspace (File | Switch Workspace | Other) with the directory created by
virtualenvas the workspace’s location – for example,C:\proj\myproj - Create a new PyDev project, and be sure to set the interpreter to be the instance of
python.exethat’s inside yourvirtualenv– for example,C:\proj\myproject\Scripts\python.exe– and to only select the folders under toC:\proj\myproject\for addition to the systemPYTHONPATH(these should be selected automatically) - Right-click on the new project in the Package Explorer window, and select Team | Share Project
- Enter the location of your repository, and select Finish
At this point, your project is good to work on, and correctly initialized into a subversion repository. When using virtualenv, it’s important to have each environment in its own Eclipse workspace, to ensure that only packages the runtime can see are those which have been installed into that particular environment.
It’s also important that you activate the virtualenv with something like $ C:\proj\myproj\Scripts\activate.bat before you use easy_install to add any packages. After activation, the DOS prompt will change to have something like (myproj) preappended to it, which indicates that easy_install (or any other setuptools used) will impact the virtualenv, and not overall system. If you don’t do this, you’ll install the packages into the system-wide Python insallation, which defeats the point of using virtualenv.
Hi Daniel, thank you for a short and functional howto. I use different platform, but information about Eclipse/Django helped me. Jakub