Many new programmers are often told to learn Python as their first programming language, which I totally agree with! However, for many, setting up a basic "environment" can seem extremely daunting. Which version of python should I use? What program should I use to code in? This tutorial tells me to use numpy, how do I get that?
Well, in this short tutorial I will show you the basics of how to set up your own coding environment for python, and can even be extended to other languages once you decide to learn another!
Installing Python
If you've been using websites like repl.it since getting started, you'll need to take some extra steps to set up python on your computer if you want to start making more powerful projects.
Head on over to https://www.python.org/downloads/ and download python for your respective operating system.
Note, as of the time of writing, python 3.9 has been released, however I would be wary of downloading this latest version, as some important packages, like numpy and matplotlib may not be supported. I would recommend downloading 3.7 or 3.8 instead, unless this article has been out for a while.
Python 2 vs Python 3
Just a quick tangent, but you might not know the difference between Python 2 and Python 3. Python 2 is an older version of Python. It is mainly kept for support for older programs. You should learn and use Python 3 unless it is necessary to use Python 2.
With that out of the way, go ahead and download and install Python by running the installer. If the installer asks if you want to add python to your PATH variable, tell it yes. If it asks you to restart your computer, do that as well after installation. This will allow you to run python from the command prompt.
And you've now installed Python! Next up we'll be installing the tools we use to actually code.
Installing Visual Studio Code
This part is simple. Now that you've got Python set up, its time to download your coding "environment". A coding environment is where you will develop, run and debug your programs. Visual Studio Code is Free, maintained by Microsoft, and works on most computers. Some other alternatives are Sublime, Atom and even just plain old Notepad. Those will not be covered here.
Just go to https://code.visualstudio.com/ and download and install VSCode!
Finishing up
Now that you have Python and Visual Studio Code installed, its time to start your first project!
Open VSCode and pick a folder where you want to keep your projects. Somewhere in your Documents on your computer is usually good. Now, make a new Python file, like [test.py](http://test.py)
and open it.
After opening the file, VSCode might ask if you want to install the Python extension and PyLint. Install those.
Now you're essentially good to go! To test, add a line of code like print("Hello World")
, press Shift+F5 (or F5 and Enter to go into debug mode) and Viola! Your code will run in the command prompt below.
Top comments (0)