Published on: 27 Oct, 2021
Updated on: 28 Dec, 2023
Setting up Python environment on your system
Here we explore how we can quickly set up a Python interpreter on our system
Here, we will be exploring how to set up Python 3.x on our system. Basically, Python
comes with 2 flavors - Python 2
and Python 3
. But, Python Software Foundation has
completely deprecated Python 2 recently in January 2020 and hence we will be setting up Python 3
👉 NOTE: In case you want to learn more about Python deprecation, please refer - https://www.infoq.com/news/2019/09/python-2-end-of-life-approaching/
1. Setting up Python 3.x
As per Wikipedia definition, Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991.
But, actually speaking its much more than this. Today, Python has gained such popularity among the developers' community, it has become one of the top 3 widely-used programming languages.
👉 NOTE: In case you want to learn more about Python ranking, please refer - https://redmonk.com/sogrady/2020/02/28/language-rankings-1-20/
So let's get started and dive into the setting up of Python 3.x on our system
Firstly, we have to check whether we have Python installed on your machine or not using:
python --version
Once we execute this and if we have already python installed and PATH is set, then we will get below output
Python 3.x.x
And, in case we received - python has not recognized or python not found or something else then we need to install Python and set the environmental variable PATH
So, let's consider we don't have Python installed on our systems and we have to do the set up from scratch.
For Windows users
Follow the below steps to set up Python on your system:
- Go to https://www.python.org/downloads/
- Download respective executable/binary file based on system. By default, you will get executable/binary file based on your system. Just click on - Download Python <version no.>
- Run the downloaded executable file and follow the instructions.
- Once the installation is done successfully, let's set up Python environmental variable path
I know you guys can do it on your own 😎
2. Setting up Python environmental variable
After successful installation of Python, we must set the path of Python folder as a part of environmental variable to avoid the unexpected error or we can say to work with Python through cmd/terminal
So, let's see how to set up enviromental variable path for Python.
For window users
- Go to "My Computers/Computers"
- Right-click & select "Properties"
- In the left panel, click on "Advanced System Properties"
- Click on "Environmental Variables"
- Under the System Variables section, select "Path" and click "Edit"
- Click on "Add" button and add the path of Python folders as follows
C:\Program Files\Python38;
👉 NOTE: In case you need more details, please visit - https://docs.python.org/3.8/using/windows.html#excursus-setting-environment-variables
For Mac & Linux users
In case of Mac system we don't need to explicitly set the PATH for Python since Mac already comes with Python installed but mostly those installed Python version are the older version such as Python 2.7
So, to installed latest version of Python on Mac & Linux we need to follow the steps above. Here, we will be dicsussing how we need to set up latest installed Python path
- Open terminal and create ".bash_profile"
- Open the file using any of the text editor "Sublime Text/ Atom/ VS Code"
- Also, you can use built in text editors such as "Vim / nano"
- Add the below lines".bash_profile"
- After adding, save the file and execute below command
- Close the terminal and open again and run
python --version
- If things went well then we will get
Python 3.x.x
vim .bash_profile or nano .bash_profile
export PATH="$PATH:/usr/local/bin/python"
source .bash_profile
3. Accessing Python 2 and Python 3
In case you have Python 2 and Python 3 both installed on your system, to access Python 3 we can simply open terminal/CMD and run
python3
YEEEE !!! 🤗, we have set Python interpreter on our local system. Let's explore more about Python
Here are similar posts
We have more silimar posts that you would love to checkout