Skip to content

Instantly share code, notes, and snippets.

@frfahim
Last active April 28, 2024 17:13
Show Gist options
  • Save frfahim/73c0fad6350332cef7a653bcd762f08d to your computer and use it in GitHub Desktop.
Save frfahim/73c0fad6350332cef7a653bcd762f08d to your computer and use it in GitHub Desktop.
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 

Now create a virtual environment

virtualenv venv 

you can use any name insted of venv

You can also use a Python interpreter of your choice

virtualenv -p /usr/bin/python2.7 venv

Active your virtual environment:

source venv/bin/activate

Using fish shell:

source venv/bin/activate.fish

To deactivate:

deactivate

Create virtualenv using Python3

virtualenv -p python3 myenv

Instead of using virtualenv you can use this command in Python3

python3 -m venv myenv

Install pip3

sudo apt-get install -y python3-pip

to install package

pip3 install package_name

setup few more packages and development tools

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

install venv module

sudo apt-get install -y python3-venv

create a enviornments

python3 -m venv project_env

@DianaLozanoP
Copy link

DianaLozanoP commented Jul 31, 2023

Hey @BakrFrag,
I followed your suggestions, and they worked wonders.
Now I can use a virtual environment.
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment