This is a follow up to a previous
tirade post about how to set up Python to run 3rd party scientific code. As I edited that article to acknowledge, it did contain some inaccuracies due to the fact that I was in a rush at the time. Now that I’ve been able to do my own research at a more reasonable pace, I’ve been able to put together some steps to setting up an all 64-bit Python 3.3+ IDE. Since this is a bleeding edge guide, it does not cover Python 2.*, but the steps for that version family should be similar and even easier.
Step 1: Install Python
Download and install the latest (highest version number) Windows X86-64 version of Python here. Check the “Compile files to byte code after installation” option – it isn’t absolutely necessary, but can result in a marginal speedup of executed code later on. We will call the version of Python you install in this step version A.B.
Don’t worry about losing support for other versions by installing the latest, you can run as many versions of Python on a single machine as you want (however, only 1 can be added to your environment variables). Just about all IDEs will allow you to specify which version to use on a per-project basis, meaning that you can have multiple projects which use different versions.
Step 2: Install x64 builds of any necessary packages
Lots of benevolent developers have created useful Python libraries for scientific computing. Unfortunately, not all of those are available as official x64 builds. Fortunately, Christoph Gohlke has unofficial x64 builds for a vast number of those – including NumPy, SciPy, and matplotlib – here.* Before downloading from that page, click the link to each desired package’s official website to ensure there isn’t an official x64 build available directly from the developers. If you choose to download from Christoph, select the installer ending in win-amd64-pyA.B.exe.
Generally speaking, all Python library installers are named after the Python version they correspond to, so the installer you’re looking for should always contain “64” and “A.B” in the filename. If you do not see either of those, then you’ll either have to find an unofficial x64 build for your Python version or download the source code and compile the library yourself.
Step 3: Install and set up an IDE
There are quite a few IDEs available for Python. Of those with official Python 3.3+ support,** PyDev and Python Tools for Visual Studio (VS2012) have the most features. PyDev is free, while Visual Studio 2012 isn’t. Also, Visual Studio isn’t available as an x64 application, but unlike most Python-related things it can both target and use 64-bit packages and executables without being 64-bit itself. In my experience, setting up PyDev is a bit more involved, but it also runs faster than VS2012. VS2012 has a much more attractive UI, though. Unlike Eclipse, it doesn’t require Java if you’re biased against that sort of thing.
Installing and setting up PyDev
PyDev is actually an Eclipse plugin. You’ll need to download and install Java first if you haven’t already (sorry). Next, download the highest version number Windows 64 Bit build of the Eclipse Classic here. Eclipse’s developers apparently fall into the pro-portable/anti-installation camp, so unzip the downloaded archive, then drop the \eclipse folder into C:\Program Files. Launch the IDE from C:\Program Files\eclipse\eclipse.exe – you might wanna create a shortcut for this yourself – and then follow these instructions.
Installing and setting up Python Tools for Visual Studio
As with PyDev, Python Tools is also a free/OSS plugin, albeit for a non-free, closed source IDE (Visual Studio 2012). Unlike PyDev, it has full official long term support from a major vendor.
You’ll need to get Visual Studio first. Hopefully you have a site license, because that’s not exactly cheap. Download and install it. VS2012 takes a while to get done installing if you check all the options, so you might wanna take a break. Click LAUNCH when the installer is complete. Check the option to join the Microsoft Customer Experience Improvement Program: MS actually uses this to fix bugs and make future design decisions. Install updates if you’re prompted for them.
Next, download and install Python Tools from here, then follow these instructions. You should be able to reuse the \src directory from the PyDev setup above for an example case. Note that you’ll need to specify a Startup file in Visual Studio to actually run code. Find the example.py file from the PyDev setup tutorial in the Visual Studio Solution Explorer, right click on it and click “Set as Startup File.” This tells VS2012 to run that file first when you click Start in the main menu to evaluate your code.
And that’s all there is to it. Now you have a completely x64 Python dev setup. Enjoy!
*The Python ecosystem definitely has the “Some Random Guy” ethos – in which you run code downloaded from sparse webpages and somehow trust that it’s stable and non-malicious – common to many non-consumer oriented open source projects. It lacks the spit and polish seen in commercial packages and may take some getting used to.
**The much ballyhooed Python(x,y) and Spyder don’t fall into this group