Python environment configuration
Python Environment Configuration, before you start learning Python, the most important thing is – yes, you need to install the Python environment. Many beginners struggle with whether to choose version 2.x or 3.x. In my opinion, the world is changing at an ever-increasing pace, and so are language updates. There’s no reason to dwell on the past and not look forward. With its growing popularity and numerous cool new features, there’s really no reason to reject Python 3.x. If you understand the need for Python and the fact that life is short, you should choose this future-oriented development model.
Therefore, our tutorials will be based on the latest Python 3.x version. Please ensure you have the corresponding version installed on your computer.
Installing Python on Windows
Step 1
Download the appropriate Python version from the official Python website: https://www.python.org/downloads/
Then, run the downloaded EXE installation package:
Make sure to check Add Python 3.6 to PATH
, then click Install Now
to complete the installation. By default, it will be installed in the C:Python36
directory.
Step 2
Open a command prompt window (click “Start” – “Run” – type “cmd”) and type Python
. Two scenarios will occur:
- Scenario 1:
Seeing the above screen indicates that Python has been successfully installed!
When you see the prompt >>>
, you are now in the Python interactive environment. You can enter any Python code and press Enter to see the result immediately. Now, close the command prompt window to exit the Python interactive environment.
Situation 2: You get an error:
‘Python’ is not recognized as an internal or external command, operable program or batch file.
This is because Windows searches for Python.exe according to the path set by the Path environment variable. If it can’t find it, an error message will be displayed. If you forgot to check Add Python 3.6 to PATH
during installation, you must manually add the path to Python.exe to your Path. If you don’t know how to modify environment variables, it’s recommended to rerun the Python installer and make sure to check Add Python 3.6 to PATH
.
Installing Python on a Mac
If you’re using a Mac running OS X 10.8-10, the default Python version is 2.7. You’ll need to install the latest Python 3.x.
Step 1:
- Method 1: Download and Install
Download the Python installer from the official Python website.
Then simply click Continue to complete the installation. -
Method 2: Install with Homebrew
If you have Homebrew installed, you can install it directly using the commandbrew install Python3
.
Step 2:
If you’re still unsure, you can double-check. To do this, open a terminal and enter Python3
(not Python 3
or Python
).
If you get this result, the installation is successful.
Installing Python on Linux
The good news is that most Linux systems have a built-in Python environment. For example, Ubuntu, starting with version 13.04, has both Python 2 and Python 3 built-in, which is perfectly sufficient and doesn’t require further installation.
If you want to check your Python version, open a terminal and enter:
python3 --version
This will show you the Python 3 version.
If you need to install a specific version of Python, enter this line in the terminal:
sudo apt-get install python3.6
Replace 3.6
with the version you need.