Setting Up Python Virtual Environments on Windows and Linux

Learn Tricking
2 min readApr 26, 2024

A Python virtual environment is like a separate workspace for your Python projects. It’s a way to work on one project without changing anything in your other projects. With virtual environments, you can have different versions of Python and packages for each project. This helps keep your projects organized and avoids conflicts between them.

Creating a Python virtual environment in Linux:

1. If you don’t have pip (Python package installer) installed, you can install it using:

sudo apt-get install python-pip

2. Next, install virtualenv, a tool for creating virtual environments:

pip install virtualenv

3. Check your virtualenv installation:

virtualenv --version

4. Create a new virtual environment:

virtualenv myenv

Replace `myenv` with the name you want for your virtual environment. If you want to use a specific Python version, you can specify it:

virtualenv -p /usr/bin/python3 myenv

5. Activate the virtual environment:

source myenv/bin/activate

Your command prompt should now show the name of your virtual environment, indicating that you are working inside it.

6. To deactivate the virtual environment and return to your regular system environment, simply type:

deactivate

This way, you can create and manage isolated Python environments for different projects on your Linux system.

Don’t Miss: Changing Numbers into Text in Python with num2words Library

Creating a Python virtual environment in Windows:

1. If you already have Python installed, you can use pip to install virtualenv:

CLICK HERE TO CONTINUE

--

--

Learn Tricking

Learn programming languages like python, php, java, c++. You can also learn cyber security, ethical hacking, termux, kali linux web devep, seo and monitization.