Creating and using virtualenv

To create a virtualenv, run

virtualenv NAME_OF_VIRTUALENV
virtualenv

On Ubuntu 18, this command will create virtualenv with Python 2.7.

To create virtualenv with Python 3, run

Advertisement

virtualenv --python=/usr/bin/python3 venv

Here “venv” is my virtualenv name.

python3 virtualenv

To activate virtialenv, go to the folder where your virtialenv folder is present, then run

source venv/bin/activate

You will see name of your virtualenv on the command promt. To exit out of virtualenv, run

deactivate

This can be run from any folder.

Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement