Python Virtual Environment

Python is a versatile programming language with strengths in scripting, data analysis, data science, machine learning, back-end development, and automation. In this article, I’ll walk you through how to set up and create a Python virtual environment for Windows, macOS, and Linux.

Installing pip

The first step to set up a virtual environment is to download Python from python.org. After downloading and installing Python the next thing you need to do is to install pip in your systems.

Also, Read – Machine Learning Full Course for free.

Pip is a tool that is used to install, manage and upgrade the python programming packages that we use in the development. You can simply install the pip by executing the command below in your terminal or command prompt:

pip install pip

After installing the pip in your systems you can use it to install any Python package in your systems. For example; if you want to install a popular python package known as Matplotlib you can install it by executing the command below in your command prompt or terminal:

pip install matplotlib

The term Matplotlib is the name of a Python package and it will be replaced by any package name that you need to install.

Once you are done with setting up and installing the Python programming language and pip then you can move further to set up and create a Python virtual environment in Windows, macOS, and Linux.

Set up and Create a Python Virtual Environment

Virtual environments enable us to have a virtual space for the development projects, which ensures that every project have its dependencies and the dependencies of each project do not affect another project and the dependencies.

In simple words, it is just a directory or folder on your system that has few scripts in it that makes it act like a project development environment.

To set up and create a Python virtual environment you need to install a Python package known as Venv. To install Venv you need to execute the command below in your command prompt or terminal:

pip install virtualenv

Now after installing venv, we can now set up the Python virtual environment. To do so we need to open a new folder or directory in the command prompt. Once you are in a directory where you want to create the Python virtual environment just write and execute the command below:

python -m venv folder_name

After executing the above command you need to activate your virtual environment. To do so just write and execute the command below in the same directory:

source folder_name/bin/activate

So with this, you will end up setting up the virtual environment in your systems. I hope you liked this article on how to set up and create a virtual environment in Windows, macOS, and Linux.

Aman Kharwal
Aman Kharwal

Data Strategist at Statso. My aim is to decode data science for the real world in the most simple words.

Articles: 1609

Leave a Reply

Discover more from thecleverprogrammer

Subscribe now to keep reading and get access to the full archive.

Continue reading