Link: https://www.microsoft.com/web/downloads/platform.aspx
Search for Python in WPI
- Choose either Python 3.X.X or Python 2.7.X, depending on what you require
- You can install both side by side
- Once installed, search for IDLE in your start menu and run it
- A IDLE shell window should pop up with:
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
- Execute single line commands for fun!
>>> print("hello world")
- Output:
hello world
- In the IDLE shell window, go to:
File > new file
(or new window, depending on python version) - In the new window that appears, type
print("hello world")
, and clickRun > Run module
(or pressF5
) - You will be prompted to save the file first
- Once saved, the script will run, and the output will be printed on the IDLE window
That's all! IDLE is sufficient for everyday use. If you are interested, check out Visual Studio 2017. (Community version is free. Note that you can let VS2017 install a copy of Python)
For good text editors, check out Sublime Text, Brackets or Atom.
- Open a command prompt window
- Type 'python' and press enter
- If you get "'python' is not recognized as an internal or external command, operable program or batch file.", read on
- Locate your Python installation
- It should either be in C:\ (eg.
C:\Python27
,C:\Users\[UserName]\AppData\Local\Programs\Python\Python36-32
,C:\Program Files\Python36
) - If you can't find it, do a system-wide search for "python"
- The folder you want contains the
python.exe
file (orpython3.exe
, maybe)
- It should either be in C:\ (eg.
- Once you have your Python installation folder location, follow the guide here to add it to your path variable
It is a shortcut to the executable file (.exe) in your folder. Benefit = Less typing.
- Lets say your python compiler is found at
C:\Python\python.exe
and your python script is atC:\Documents\myscript.py
- These are known as fully qualified paths.
- To compile your program, you would need to type the following in your terminal:
- If in Python folder:
python C:\Documents\myscript.py
- If in myscript folder:
C:\Python\python.exe myscript.py
- Anywhere else:
C:\Python\python.exe C:\Documents\myscript.py
- If in Python folder:
- As you can see, it is in the format: executable script.py
- Adding a folder to your PATH allows the executable to be accessed regardless of where you are in the command terminal. i.e.:
- If in myscript folder
python myscript.py
notice that this is very very short! - Anywhere else:
python C:\Documents\myscript.py
- If in myscript folder
- Open a command window
- Run your python compiler
- Simply,
python
, or if the path is not configured, use the fully qualified path
- Simply,
- You should see the following output:
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
- Notice your Python version is printed there.
- Execute single line commands for fun!
>>> print("hello world")
- Output:
hello world
- To exit your compiler, type
exit()
or pressctrl+z
andenter
Congratulations! You have completed your Python setup!
- Add
[PythonInstallationPath]/Scripts
to your PATH variable - Also check if the folder contains
pip.exe
or other versions of it - This allows you to use
pip install [package name]
to get other python packages - If you don't think its necessary to add this to your PATH variables, simply navigate to this folder and run the
pip install [package name]
when you need another package