A Virtual Environment is a python environment, that is an isolated working copy of Python which 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 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
$ 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
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
> virtualenv myenv
And here also you can name it anything.
3) Now if you are same directory then type,
You can explicitly specify your path too.
Similarly like Linux you can deactivate it like
- Python Virtual Environment | Introduction
- Set up virtual environment for Python using Anaconda
- Create virtual environment using venv | Python
- Using mkvirtualenv to create new Virtual Environment - Python
- How to Install Python Pandas on Windows and Linux?
- How to install requests in Python - For windows, linux, mac
- How to run Linux Commands on Windows 10?
- Wi-Fi Password of All Connected Networks in Windows/Linux
- Python | Add packages to Anaconda environment
- Python - Setting up the Bokeh Environment
- Why Linux Hosting is Cheaper than Windows Hosting ?
- IDE for Python programming on Windows
- How to add Python to Windows PATH?
- How to install Python on Windows?
- How to install Python Pycharm on Windows?
- How to Install Python Tensorflow in Windows?
- Windows 10 Toast Notifications with Python
- How to install OpenCV for Python in Windows?
- Autorun a Python script on windows startup
- How to Setup Sublime Text 3 for Python in Windows?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.