When you have installed Python, the question arises – how to start learning this language? Should I write commands through the console or do I need to install something else on the computer? There are many programming environments and solutions for Python, but for a beginner, it is preferable to choose from two:
- if you are learning Python for scientific purposes, then download Anaconda from www.continuum.io/downloads – this environment already includes Python, as well as such useful programs for programming and analytics as Spyder, Jupyter, IPython, R and others.
- you are learning Python for general development, then install the cool Sublime Text code editor from sublimetext.com; in this case, you will need to manually configure the Python interpreter to run the program written in this editor.
How to set up a Python interpreter on a computer manually?
- go to the folder where Python is installed and rename the Python.exe startup file to python.exe (in small letters);
- Copy the path to this file on your computer in the form D:\User\……\python.exe;
- Open Sublime Text, select Tools ->Build System->New Build System from the menu (you can try choosing Python, but sometimes it doesn’t work, so it’s better to set it up manually);
- You will see an empty view system
{
“shell_cmd”: “make”
}
You need to copy and paste the following code instead (put a double backslash in the path to the python.exe file):
{
“cmd”: [“D:\\Users\\…\\python.exe”, “-i”, “-u”, “$file”],
“file_regex”: “^[ ]File \”(…?)\”, line ([0-9]*)”,
“selector”: “source.python”
}
Save as Python.sublime-build or any meaningful name instead of Python in the …SublimeText3/Packages/User folder
Now, if you are using Sublime Text, you can make a new Python file:
- Click Save as and go to the desktop or another folder where you want to save the code file;
- Come up with a name, for example, Kod;
Add the .py extension after the name
This is your Python file. Now we need to activate the Python interpreter that we set via Python.sublime-build: go to Tools->Build System->Python (the second one you created yourself).
You can check the success of the interpreter setup like this:
import sys
print(sys.version)
To run the code in Sublime Text press Ctrl+B (this is Build):