You might have heard and have been recommended code editors like VSCode, Atom, Sublime Text, PyCharm, Spyder and Jupyter Notebooks and tools like Anaconda, Miniconda, PipEnv, VirtualEnv, etc. Code editors are all pretty much the same. You type your code, you click/press a key combination and your code just runs. Some of them are harder to set up for an easy use, some are easy. When you are just starting out, you need to ignore all of that choice and focus on a stable and easy to use setup. So let’s do it.
If you are new to programming, python, tools, I suggest using exactly the same tools as the community you are a part of to avoid losing time and motivation by “fighting” problems with your code editor and instead be productive by writing actual code.
The editor I use in my work, all of my videos and articles is VSCodium (FOSS version of VSCode). This is what we are going to set up in this article. VSCode and VSCodium are exactly the same, VSCodium just does not have any proprietary Microsoft telemetry code in it, which is totally irrelevant if you are just starting out.
Step 1: Download and Install Python and the editor.
Make sure you have the latest Python installed on your system. Even if you do, re-installing it to be the latest version is recommended. If you are on the Mac or Windows, there is an amazing video here:
If you are just a beginner, I suggest using VSCode: https://code.visualstudio.com/
Installing it on Linux and Windows is just downloading the file and running it. If you are on the Mac and not sure how to install it after you have downloaded the file, please watch this short video here.
If you are a bit more adventurous and care about running only fully free and open-source software, grab VSCodium from here: https://vscodium.com/
After you have installed it and run it for the first time, you should be presented with this view:
Step 2: Install plugins.
Now, let’s make our editor more user-friendly. In your editor, click the ‘cube’ icon and search for ‘Python’:
Choose the first one in the list and click ‘install’. This will add full Python support to our editor, enable code formatting, error reporting, and auto-completion (helps you to write code by completing lines of code for you).
Now we need another extension, that will allow us to execute our code easily. Search for ‘code runner’ and click ‘install’:
Alright. Now you have the bare minimum to start writing and executing the code. Nothing else is needed. Restart your editor.
Step 3: Run your first line of code.
Create a new file, (File -> New File), name it test.py. Now you might also see a pop-up notification “Linter pylint is not installed“:
Just click ‘Install’ and wait for it to install.
Now, in our new test.py file start typing:
If everything is running correctly, you should see that your editor is helping you by auto-completing your code.
Now we are ready to run this code by using the following key combinations:
- [Ctrl + Alt + N] on Windows/Linux
- [Control + Option + N] on the MAC
You should see Hello World printed in your output.
This is it. Now you are ready to create any Python file and just use that key combination to execute your code.
In a case if you are on Linux and your distribution still uses older, Python 2 as a default Python version, you should make sure Python 3 is installed and make it a default Python on your system:
update-alternatives --remove python /usr/bin/python2 update-alternatives --install /usr/bin/python python /usr/bin/python3 10
You can now focus on learning Python and quickly execute your code. You don’t need anything else. I talk about a few additional steps you can take to make your code editing experience even better, in my video below, but it is not needed if you are just starting.