Getting Python up and running on Windows in 5 minutes


Recently, I have had a lot of conversations about Python and been getting a lot of questions on how to get started with Python (for data analysis, data science and automation). So I wanted to write about my python setup for “Data Science”. And since the majority of you that I talked to were using Windows, this post is for you.

Since I prefer unix-like OS, most of my favorite tools are cross platform, so even if you’re using a mac or some flavor of Linux, this guide will be useful for you too.

Who is this for?

  • This is for you if you are someone who’s trying to get started with Python on Windows. (Mac & Linux too!)

  • This is for you if a Data Analyst or Data Scientist used to a unix environment but need to use a Windows device.

  • This is for you if you like seeing other people’s setups and find/try new tools.

Let’s dive in!

Installing everything:

1) Download Anaconda, Python 3.7 (or 3.8 when it’s available). Pick the “64-Bit Graphical Installer”.

  • Default installation options are fine.
  • Anaconda packages up a lot of the commonly used python packages so that you don’t have to install it separately. It’s pretty convenient, and some packages don’t run well on Windows, but Anaconda had solved all the issues and so you can install it all in one go. You can see all the packages here if you were curious.

2) Install PyCharm Community Edition and Atom Text Editor

  • Default installation options are fine.
  • PyCharm is by far the best IDE (Integrated Development Environment) for python, there are a ton of useful things it can do.
    • Here’s a youtube series by JetBrains of PyCharm showing off some of PyCharm’s features.
    • I can see how it can be really intimidating to use PyCharm because there are so many functionalities. But stick with it, it gets easier and more productive with time.
  • Atom is my favorite lightweight text editor, it has a lot of great packages that the community had built.

3) Install Git for Windows, you will need it for version control and collaboration.

  • Get the 64-bit one. For installation option:
    • “Choose the default editor used by Git”: Use the Nano editor by default
      • If you’re a newbie, it’s easier than vim, trust me.
    • “Adjusting your PATH environment”: Git from the command line and also from 3rd-party software
    • The other default options for installation are fine.
  • Git is used for version control. You can commit (save) your code at various points, and if you ever need to get code from a previous commit, it acts like a save point, so you can go back in time and get your code back.
    • Check out the videos here just to get started, and know/google these commands:
      • git status, git add, git commit, git log, git branch, git checkout
      • git clone, git pull, git push

Okay everything’s installed, now what do I do?

1) Open up Anaconda Prompt

  • Press your Windows Key, type Anaconda Prompt, it should show up.
  • Anaconda is command prompt, so any of command prompt tools will work here (dir, cd … etc).
    • See more commands here.

2) Type jupyter notebook in the Anaconda Prompt

This fires up jupyter notebook. Jupyter Notebook is your bread and butter, this is where you will do a lot of your work.

  • You can click around and explore here.
    • Jupyter notebook initiates at the same working directory that anaconda prompt is at, so:
      • We can change your working directory by:
        • Resume focus (click on) anaconda prompt, then press Control+C twice to stop jupyter notebook.
        • Change Directory (cd) to your Desktop by typing cd Desktop into anaconda prompt
          • Here’s a link to command prompt commands that you should learn!
          • Code Academy has a tutorial on bash/sh too
        • Run jupyter notebook again, you should see all the files on your desktop
  • There’s a different way to launch jupyter notebook and that’s by using Anaconda Navigator:

    • I don’t recommend it because sometimes when you “quit” jupyter notebook by closing your browser, but it actually didn’t stop jupyter notebook and you might have to restart your computer in order to stop and relaunch jupyter notebook again.

3) Create a Notebook and write code

  • Now that you have jupyter notebook up, create any folders to organize however you like, and then click “New” > “Python 3”.
  • Inside, you can type in python code and click run (or Shift+Enter) and it will run.
  • You can type in print('hello world!') as an example.

4) Before you go wild, clone your base environment and work in that new environment from now on.

  • Clone your environment and work in the new environment so that if anything ever goes wrong, you can clone a new one for a fresh start.

  • conda env list will list all your environments.
  • conda create --name myfirstenv --clone base will clone your base environment to a new environment named ‘myfirstenv’.
    • If your new environment became broken somehow you can always clone your base environment for a fresh start.
  • conda activate myfirstenv will activate your newly created environment.
    • You will have to re-issue this command everytime you open up an anaconda prompt
    • Notice how your terminal now say (mynewenv) C:\Users\UserName> instead of (base) C:\Users\UserName>

Customize your environment

My must-do’s:

Install m2-base for your anaconda prompt.

  • Open up Ancaonda Prompt, type/run: conda install m2-base, type y to confirm installation.

  • It lets you use common linux commands like clear, ls -la, grep … etc

  • I love this, this lets me use all the bash commands instead of window’s command prompt.

Install jupytext for your Jupyter Notebook

  • conda install -c conda-forge jupytext

  • jupytext automatically syncs .ipynb files with .py files. So that way your jupyter notebook will always have a .py file that you can run directly (python

  • To configure it so that all notebook automatically have a companion .py file:

    • jupyter notebook --generate Generate config file for jupyter notebook
    • Open up a file explorer and navigate to C:\Users\yourusername\.jupyter, you might need to show hidden files.
    • Open up the config file .jupyter/ in Atom

    • Add the following line, anywhere:
        c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"
        # Always pair ipynb notebooks to py files
        c.ContentsManager.default_jupytext_formats = "ipynb,py"

    • If you have jupyter notebook running, kill it (control+c) and start it again and when you open up your notebook and save (Control+S), it should generate a .py file alongside with it.
    • Now when you edit your .py file or .ipynb, both files will be synced.

Get jupyter_contrib_nbextensions

  • conda install -c conda-forge jupyter_contrib_nbextensions

  • Relaunch jupyter notebook and you should see it on your jupyter notebook UI.
  • Here are some of my favorites:
    • Execute Time
    • Codefolding
    • Table of Contents
    • Variable Inspector

Dark themes I like:

1) Get Material Theme UI for your PyCharm.

2) Get Material UI Theme for Atom.

3) Get jupyter-themes for your jupyter notebook.

  • pip install jupyterthemes
  • This is great. I use firacode on both my jupyter notebook and PyCharm.
  • I use this setup (run it in anaconda prompt):
      jt -T -t onedork -f firacode -fs 9 -tf firacode -tfs 9 -nfs 9 -cellw 980
    • Refresh and you should now have dark theme. If not, hard refresh or relaunch jupyter notebook.

What’s next?

  • Write code, practice, find data to explore, ask questions about the data.
  • Learn Git, if you don’t know already.
  • Learn basic commands on the command line.

I’ll have another post up on how to schedule scripts for with different anaconda environment on Windows. Stay tuned - coming soon.

More useful tools

  • Docker Desktop
    • You can define your container’s environment specifically, and is useful to run things that just doesn’t run on windows. I’ll write a bit more on docker in the future.
    • Check out these images by continuumio/anaconda3 and jupyter
  • F.lux
    • Blue light (think screens/monitors) mess with your sleep. Use flux to make your screen warmer (color temperature, aka less blue light).

Thoughts, comments?:

Reach out on LinkedIn or email.