How To Set Up Python Dev Env on Windows 8.1 (Python 3.4.2 doesn’t work – use 3.5.2 instead)

How To Set Up Python Dev Env on Windows 8.1 (Python 3.4.2 doesn’t work – use 3.5.2 instead)

You may skip Steps one – three if using Python v. 3.5.2, however it is recommended to complete them anyway.

1. Installing Tk on Windows at http://www.tkdocs.com/tutorial/install.html

2. setuptools 28.3.0 at https://pypi.python.org/pypi/setuptools – official installation instructions

3. more detailed: Getting a Python dev environment setup on Windows at

https://kyle.io/2012/09/getting-a-python-dev-environment-setup-on-windows/#comment-32598:

Getting “pip” on is a bit more complicated – you have to install “easy_install”, then use that to install “pip”. So, I used the lovely directions at StackOverflow for inspiration:

  1. Grab setuptools from pypi.python.org/pypi/setuptools#files – make sure the version you get matches the version of Python installed – in my case, 2.7. (*Note to course student – We’re using 3.5.2)

  2. Install setuptools. You can follow the defaults, just make sure you install to the correct directory – where you installed Python. This should be auto-detected though.

  3. Open Powershell (I’m running Win 7; if you aren’t, you should be. And if you can’t run W7, open up command prompt instead.)

  4. In the shell, change to the directory where you installed Python, and then to the Scripts directory in that folder – ie. cd C:\Python27\Scripts

  5. Type: easy_install pip – this works because setuptools added an executable called easy_install.exe to the Scripts/ folder

  6. P ip is now installed. If you want to install something with Pip (i.e. ), open up Powershell again if it’s not already open, change to that directory, and run ./pip install requests

Step 2’s file = https://bootstrap.pypa.io/ez_setup.py. Save this file somewhere easy to access on your computer. Then, in command prompt, change directories (cd) to the folder containing the ez_setup.py file (or whatever name you use) and type:

python ez_setup.py

This will tell python to set up the “setuptools” which gives you “pip”.

4. You can now follow instructions about Sms-Tools at https://github.com/MTG/sms-tools to install the other python tools, such as “ipython” using “pip”. Type:

pip install ipython numpy matplotlib cython scipy (This will give errors, so instead, type: pip install ipython matplotlib

*Notice that “cython” must be installed before scipy can be installed.

a. To install “numpy,” follow these instructions from http://stackoverflow.com/questions/24009413/numpy-wont-install-in-python-3-4-0-in-win7:

  1. Download “numpy-1.11.2+mkl-cp35-cp35m-win_amd64.whl” file** from
    http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

  2. Copy this file to C:\Python35\Scripts

  3. In cmd.exe, run command as pip install “numpy-1.11.2+mkl-cp35-cp35m-win_amd64.whl”

These steps will be easier for you to install NumPy, SciPy, SciKit-Learn or any other packages in Python.

** I updated the name of the appropriate file, so it’s different than the one originally posted FYI

b. To install “scipy”, follow the same steps for installing “numpy”, that is:

i. Download “scipy-0.18.1-cp34-cp34m-win_amd64.whl” file** from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

ii. Copy this file to C:\Python35\Scripts

iii. In cmd.exe, run command as pip install “scipy-0.18.1-cp34-cp34m-win_amd64.whl”

– Follow step four using files from http://www.lfd.uci.edu/~gohlke/pythonlibs and the appropriately named wheel packages, e.g., Cython-0.24.1-cp35-cp35m-win_amd64.whl

– After installing those plugins, run:

5. To compile – https://docs.python.org/3.4/using/windows.html#compiling-python-on-windows

In a command prompt window inside your Python35\Scripts folder, type the command:

python compileModule.py build_ext –inplace 

If you get the error “cannot find vcvarsall.bat” when you try to compile python in the command prompt with the command:

                                         python compileModule.py build_ext –inplace

, then check your Control Panel’s Program and Features for: Visual C++ Redistributable for Visual Studio 2015. The download is at https://www.microsoft.com/en-us/download/details.aspx?id=48145

– Then, you get an error that link.exe of Visual Studio cannot open file ‘m.lib’. To fix this, go into file called compileModule.py in path C:\whatever\your folders\sms-tools\software\models\utilFunctions_C, go to line 33 and remove “libraries=[‘m’]” from:

setup(

cmdclass = {‘build_ext’: build_ext},

ext_modules = [Extension(“utilFunctions_C”, sourcefiles, include_dirs=py_inc + np_inc)]

)

According to fgregg at https://github.com/datamade/dedupe/issues/158:

From various readings around the internet, it seems like Visual Studio does not need to link to the math library, since it does it automatically. Please remove the ‘m’ library from setup.py, and give it a try.

– Then, cd to software/models_interface/ and run the command:

python models_GUI.py

The medium-size window should appear on your display.

Proceed with the course’s sms-tools instructions at: https://github.com/MTG/sms-tools

If you have any questions or feedback, you can let me know in the comments here or on the course’s forum week 1’s post entitled “I got sms-tools working on WIndows 8.1.”

Advertisements