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.
To use the mkvirtualenv command you need to have virtualenvwrapper installed which is nothing but a set of python extension commands.
Make sure you have pip installed.
$ sudo apt-get install python3-pip
$ sudo pip3 install virtualenvwrapper
Open bashrc by –
$ sudo gedit ~/.bashrc
After opening it, add the following lines to it :
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/Devel source /usr/local/bin/virtualenvwrapper.sh
Save the bashrc file.
Using mkvirtualenv command
Now let us use it,
The syntax is :
$ mkvirtualenv venv_name
If you want to work on another version of python, try this :
$ mkvirtualenv -p python3.x venv_name $(venv_name) // You will see something like this
Note: You can use any version in place of x.
To work on an existing virtual environment,
$ workon venv_name
To get out of the virtual environment –
To see the list of your virtual environments are, go to-
- Create virtual environment using venv | Python
- Set up virtual environment for Python using Anaconda
- Python Virtual Environment | Introduction
- Creating Python Virtual Environment in Windows and Linux
- Python | Add packages to Anaconda environment
- Python - Setting up the Bokeh Environment
- PYTHONPATH Environment Variable in Python
- Environment Variables in Python
- How to create a new thread in Python
- Program to show that Linux provides time sharing environment to processes
- Set up Opencv with anaconda environment
- Environment Variables in Linux/Unix
- How to setup Anaconda path to environment variable ?
- Environment setup for CherryPy
- Environment Setup for Matplotlib
- Setting up a C++ Competitive Programming Environment
- Setup OpenCV With PyCharm Environment
- Create a new column in Pandas DataFrame based on the existing columns
- Create a shared Folder between Host OS and Guest OS ( Virtual Box)
- Create a Virtual Machine and Set up API on Google Cloud
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.