The are several alternatives for installing Python on Windows out there. However, if you’re working with scientific python packages like NumPy, SciPy, Matplotlib, OpenCV, etc, most of the times you’ll end up configuring Windows PATH, installing several Microsoft Visual C++ versions, compiling complicate things…we don’t want that! It also includes full support for PyQt!
WinPython is a standalone version of Python that brings a lot of stuff already installed and ready to use. Moreover you don’t mess with Windows PATH and you can install as many versions as you want (both Python 2 and 3!!).
How it works?
- Download WinPython;
- Extract the zip for whatever folder you want. Personally, I have a folder called “Python” where I keep both Python2 and Python3 installations;
- Navigate to the installation folder, for example “WinPython-32bit-188.8.131.52” and you’ll find some scripts inside it. “WinPython Command Prompt.exe” is the one you want. Just double click it and you have a working Python console! Simple as that!
OpenCV (with FFMPEG) support
WinPython doesn’t ship with OpenCV. However is very simple to install it.
For Python 2
- Download OpenCV for Windows (http://opencv.org/downloads.html)
Note: I only tried with OpenCV versions 3.0 and 3.1 but it should work with version2 also.
- Run the installer which essentially extracts content for a specified folder (put it wherever you want, it really doesn’t matter since you’ll remove it later on);
- Then navigate to this folder and go to “opencv\build\python\2.7”. Inside this folder you’ll find both x64 and x86 options. Choose it accordingly to your WinPython installation;
- Inside the previous folder you’ll find a single file “cv2.pyd”. Copy it to “Python\WinPython-32bit-184.108.40.206\python-2.7.10\Lib\site-packages” where “Python\WinPython-32bit-220.127.116.11” is the folder where you installed WinPython.
For Python 3
Unfortunately, at the time of this writing, OpenCV does not include binaries for Python 3. But wait! There is a simple workaround too!
- Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. Here you’ll find a list of pre-compiled binaries for Python on Windows. Download the wheel accordingly to your WinPython installation. For example, “opencv_python-3.1.0-cp34-none-win_amd64.whl” means OpenCV 3.1.0, Python 3.4 64 bits;
- Open you Python console by calling “WinPython Command Prompt.exe” from your WinPython installation;
- On the console, change dir to where you downloaded the OpenCV binary;
pip install opencv_python-3.1.0-cp34-none-win_amd64.whl
- And that’s it!
Finally, if you want OpenCV with ffmpeg support:
- Navigate to “opencv\build\bin” (inside the OpenCV extracted folder);
- You’ll find both “opencv_ffmpeg310_64.dll” and “opencv_ffmpeg310.dll” (this may vary depending on OpenCV version), choose it accordingly to your WinPython installation;
- Copy the corresponding file to “Python\WinPython-32bit-18.104.22.168\python-2.7.10\”;
- And that’s it!
Remove the OpenCV folder if you want.
Remove the downloads of WinPython and OpenCV if you want.