The Wayback Machine - https://web.archive.org/web/20240619120711/https://www.geeksforgeeks.org/creating-python-virtual-environment-windows-linux/
Open In App

Creating Python Virtual Environment in Windows and Linux

Last Updated : 22 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A Virtual Environment is a Python environment, that is an isolated working copy of Python that allows you to work on a specific project without affecting other projects So basically it is a tool that enables multiple side-by-side installations of Python, one for each project.

Creating a Python virtual environment in Linux

If pip is not in your system

$ sudo apt-get install python-pip

Then install virtualenv

$ pip install virtualenv

Now check your installation

$ virtualenv --version

Create a virtual environment now,

$ virtualenv virtualenv_name

After this command, a folder named

virtualenv_name

will be created. You can name anything to it. If you want to create a virtualenv for specific python version, type

$ virtualenv -p /usr/bin/python3 virtualenv_name

or

$ virtualenv -p /usr/bin/python2.7 virtualenv_name

Now at last we just need to activate it, using command

$ source virtualenv_name/bin/activate

Now you are in a Python virtual environment You can deactivate using

$ deactivate

Creating Python virtualenv in Windows

If python is installed in your system, then pip comes in handy. So simple steps are: 1) Install virtualenv using

 > pip install virtualenv 

2)Now in which ever directory you are, this line below will create a virtualenv there

 > python -m venv myenv

And here also you can name it anything. 3) Now if you are same directory then type,

 > myenv\Scripts\activate

You can explicitly specify your path too. Similarly like Linux you can deactivate it like

$ deactivate


Similar Reads

Using mkvirtualenv to create new Virtual Environment - Python
Virtual Environment are used If you already have a python version installed and you want to use a different version for a project without bothering the older ones. it is good practice to use a new virtual environment for different projects. There are multiple ways of creating that, today we will create one using mkvirtualenv command. virtualenvwrap
2 min read
Create virtual environment using venv | Python
Managing multiple Python projects that have conflicting dependencies can be a daunting task. However, virtual environments can help you solve this problem. With virtual environments, each project can thrive in its own sandboxed paradise with its libraries and settings. By learning how to create virtual environments using Venv, you can say goodbye t
6 min read
Python Virtual Environment | Introduction
A Python Virtual Environment is an isolated space where you can work on your Python projects, separately from your system-installed Python. You can set up your own libraries and dependencies without affecting the system Python. We will use virtualenv to create a virtual environment in Python. What is a Virtual Environment?A virtual environment is a
4 min read
Using Jupyter Notebook in Virtual Environment
In this article, we are going to see how to set Virtual Environment in Jupyter. Sometimes we want to use the Jupyter notebook in a virtual environment so that only selected packages are available in the scope of the notebook. To do this we have to add a new kernel for the virtual environment in the list of kernels available for the Jupyter notebook
2 min read
Setting Up a Virtual Environment in Django
Setting up a virtual environment in Django is essential for isolating your project's dependencies and ensuring consistent behavior across different environments. A virtual environment allows you to install packages locally without affecting the global Python installation. Here's how to set up a virtual environment for your Django project. Setting U
2 min read
How to Upgrade Pip and Python on Windows, Linux, and MacOS?
Python is a programming language with standard libraries and a great ecosystem of third-party packages. On the other side, Pip is the default package manager for Python that installs, upgrades and manages Python, including its dependencies. Pip simplifies the process of installing external libraries and tools which are written in Python. Pip allows
5 min read
Using Python Environment Variables with Python Dotenv
Python dotenv is a powerful tool that makes it easy to handle environment variables in Python applications from start to finish. It lets you easily load configuration settings from a special file (usually named .env) instead of hardcoding them. This makes your code more secure, easier to manage, and better organized. In this article, we'll see over
3 min read
Python - Install Paramiko on Windows and Linux
The high-level python API starts with the creation of a secure connection object. To have more direct control and pass a socket to transport to start remote access. As a client, it's authenticating using a user credential or private key, and checking the server’s host key. Paramiko is a Python library that makes a connection with a remote device th
1 min read
How to check Python Version : Windows, Linux and Mac
Python is a versatile and widely used programming language, and it is used for various tasks, from scripting to web development. Python, like many software, has different versions, and it's important to know which version is installed on your system.  This information is crucial because different Python versions may have variations in syntax or lib
4 min read
How to Install Requests in Python - For Windows, Linux, Mac
Requests is an elegant and simple HTTP library for Python, built for human beings. One of the most famous libraries for Python is used by developers al over the world. This article revolves around how one can install requests library of Python in Windows/ Linux/ macOS using pip. Install Requests Module in Python in Window For installing requests in
3 min read
Article Tags :
Practice Tags :