HostOnNet Blog

virtualenv

Looking for Linux Server Admin or WordPress Expert? We can help.

virtualenv allows you to have run multiple python versions and manage its library.

To install virtualenv on Ubuntu, run

sudo apt install virtualenv

Or if you have setuptools installed, run

easy_install virtualenv

You can find more info on official web site at https://virtualenv.pypa.io/

Create a VirtialEnv

Here we create a virtualenv with python3 as default version of python in Ubuntu is 2.x.

virtualenv --python=/usr/bin/python3 ~/www/python/project1

~/www/python/project1 can be any folder on your PC. Where you will be placing your Python 3 code.

Using Virtualenv

To use virtualenv, you need to go to the folder, then run

source bin/activate

To deactivate virtualenv, you can run

deactivate

Posted in Python

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.