Python Wrangler Notes

How to operate once you've set your machine up with Python Wrangler.

Python Wrangler helps you install Python in a nice, pleasant, perfect way. But what do you do once you’re done? Read on!


Your default Python

If you visit the command line and type python, it will run your “good” Python.


Installing packages (Windows)

Your usual pip install should work fine, but since we’re not using Anaconda some of the more technical packages might be trouble for Windows users.

These packages need to be compiled - converted from source code into actual runnable code - which needs extra software installed on Windows. Download and install the Visual Studio Build Tools from Microsoft and you should be good to go.

When you run the installer it’ll make you jump through some hoops, what you want to install is the Visual Studio C++ Build Tools.

Using wheel files

If it still doesn’t work or you’re too lazy to install the build tools, we can also install using wheels, which has already been compiled for us. First, install the wheel package to be able to install using wheel files.

pip install wheel

Then, download the package you need from Christopher Gohlke’s Unofficial Windows Binaries page. With Python 3.6 and 32-bit Windows, the file you want should end in -cp36‑cp36m‑win32.whl.

Finally, cd to your Downloads folder and install it using pip. It should look something like this:

cd Downloads
pip install pandas‑0.22.0‑cp36‑cp36m‑win32.whl


Creating virtual environments

If you used Python previously, you’re probably familiar with virtualenv. Well, fun update: stop using it!! Now pipenv is the official recommendation from Python.org, and it’s awesome.

  1. Visit your project directory
  2. pipenv install to create a virtual environment
  3. pipenv shell to activate it
  4. pip install ... the packages you need
  5. python ... just like normal

That’s basically it, but you can visit https://github.com/pypa/pipenv for more details.


Using Python 2 (OS X)

For OS X, We’re using pyenv to manage different versions of Python. To switch to 2.7, use the following command.

pyenv install 2.7
pyenv shell 2.7

Once you exit the shell, you’ll be back to your default Python. And you only need to use pyenv install the first time.


Using Python 2 (Windows)

Python Launcher comes installed automatically with newer versions of Python 3, and allows you to use the py command.

The py command runs whatever the latest version of Python you have is. If you’ve also installed Python 2, you can use it with -2 or -2.7 to run your script using Python 2. For example:

py -2 something.py

You can install Python 2 from Python.org, just scroll down and keep a sharp eye out.

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY