How to Create and Activate Virtual Environment In Linux ?
How to Create and Activate Virtual Environment In Linux ?
A short tutorial on creating and activating virtual environment in Linux .
Image Credit - Source |
In this short tutorial , I will be using Ubuntu Linux distro to explain the whole process of creating and activating virtual environment in Linux .
Creating virtual environment
Follow the steps below to create a virtual environment in your system .
- Open terminal in your Linux distro .You can directly press Ctrl + Alt +T to open terminal , or search ‘ terminal ’ after pressing super key and hit enter .
Source - Author |
- Create a directory you wish to use as a virtual environment . Here , I am giving directory name as ‘ virenv ’ . Your are free to give any name to the directory as per your choice . To create the directory , type ‘ mkdir directory_name ’ in the terminal as shown in the screenshot below .
Source - Author
- Type the below command in the terminal to create the virtual environment . Please ensure that you have Python 3 and virtualenv are installed in your system .
$ virtualenv -p python3 .
- Please note that there is a dot at the end of the above command which indicates that we are creating a virtual environment in the current directory . After the command is executed , you are done . Your virtual environment is created .
Source - Author How to activate the virtual environment ?
Get into your virtual environment by typing the command below in the same directory in which you have just created it .
$ source bin/activate
Comments
Post a Comment