Basic Windows Setup
This is a very basic guide to getting your Windows environment prepped and ready to run Python.
Please note that there are limitless possibilities and choices when it comes to most of these steps. The steps below only show one specific way to set things up. You are free to explore as you wish!
The steps below will have you install Notepad++ as your text editor and Miniconda as your Python interpreter.
The interpreter that this guide is recommending comes from a utility called
Miniconda. It's located here: https://conda.io/miniconda.html
There are many benefits to using this interpreter in Windows. The largest
benefit is that you do not need to install a C/C++ compiler in order to
install some Python packages (e.g.
We recommend installing the latest release of Python 3. You should only choose
Python 2 if you have a need for it. Another great thing about
that you can start with Python 3, but you can install Python 2 at a later date.
This will use conda environments (not covered here; see
the official docs).
- Download the
Python 3.6installer from https://conda.io/miniconda.html (probably 64-bit)
- Run the installer
- Select the defaults, but stop at
Advanced Installation Options.
- Wait for Miniconda to finish installing
You may need to log out and back in again. YMMV.
The best way to write Python code is with an enhanced text editor. There are a ton of options in this realm, along with opinions. Here are a few Windows applications listed in order of easiest (least features) to hardest (lots of features)
- Notepad++: Freeware, Windows only
- Some setup effort
- Most amount of effort
If you like the command-line, there's always Vim!
For the sake of this guide, we'll use Notepad++. If you grow out of the limited feature set of Notepad++, we strongly recommend moving to something else.
- Download the installer from https://notepad-plus-plus.org/
- Run the installer
- Select all of the defaults
We recommend changing your tabs so that Notepad++ will insert 4 spaces each
time you press the
Tab key on your keyboard. This will make you compliant
- Settings -> Preferences
Replace by spacein the
Tab settingssection and make sure the size is set to
Using your environment
We can finally start to write some Python code!
Create a Python script
The first step is to create a Python file. Here's one way to do it:
- Open Notepad++
File -> New; you should have a new tab
- Save the empty file with
File -> Save as...
Saving an empty file with a
.py extension will allow the editor to enable
syntax highlighting. That makes things much easier to code!
Create the Python code you want to run. Maybe this:
def say_hello(): print('Hello, World!') if __name__ == '__main__': say_hello()
Save the file when you are done editing.
Run the script
- From the start menu, select
- Change to the directory you saved your script above. Maybe:
if you saved it to you Desktop
- Run the script with
python <scriptname>. For example, if you saved your script as
hello.py, you would run:
These directions show just one of the many ways to set up a Python environment on Windows. There are many more options of interpreters, text editors, and full blown Integrated Development Environments (IDEs). We also haven't covered any of the 138,120 projects on pypi.org (as of 7-MAY-2018)!