Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Geoyi/d9fab4f609e9f75941946be45000632b to your computer and use it in GitHub Desktop.
Save Geoyi/d9fab4f609e9f75941946be45000632b 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
@bhatbhupendra
Copy link

OSError: [Errno 9] Bad file descriptor
my error while creating the virtual env

@kibablu
Copy link

kibablu commented Nov 18, 2020

Steps I followed:

sudo apt-get install python3-pip
pip3 install virtualenv 
virtualenv venv 

But I get error as:

The program 'virtualenv' is currently not installed. You can install it by typing:
sudo apt install virtualenv

use sudo apt-get update then use sudo apt-get install virtualenv

@kibablu
Copy link

kibablu commented Nov 18, 2020

OSError: [Errno 9] Bad file descriptor
my error while creating the virtual env

could you please provide more details, like

  • what OS are you using

  • what command did you run and displayed an error

  • do you have any screenshots you can share

@mursalatul
Copy link

can anyone please tell me why i cant use virtualenv in this directory? i am using ubuntu LTS 20.04
image

@kibablu
Copy link

kibablu commented Mar 31, 2021

@mursalatul could you please name dele to venv your command should look like this source venv/bin/activate
you can create venv using this command python3 -m venv venv

@amanprakashsingh
Copy link

Screenshot from 2021-04-04 01-23-15
it is telling permission denied what to do ?

@OjiboVictor
Copy link

Hi ,I have installed pip3 and the virtual environment but I'm unable to activate it. I really tried running the pip3 install virtualenv and this is what it is displaying....

C:\Users\USER>pip3 install virtualenv
Requirement already satisfied: virtualenv in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (20.4.7)
Requirement already satisfied: filelock<4,>=3.0.0 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (3.0.12)
Requirement already satisfied: six<2,>=1.9.0 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (1.16.0)
Requirement already satisfied: distlib<1,>=0.3.1 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (0.3.2)
Requirement already satisfied: appdirs<2,>=1.4.3 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (1.4.4)

Please can you help me out? Thank you

@Almistro12
Copy link

ice_screenshot_٢٠٢٢٠١١٨-٠٧٤٢١٤

@abhishekprajapati1
Copy link

Thanks. it worked for me in zorin os

@mursalatul
Copy link

@mursalatul could you please name dele to venv your command should look like this source venv/bin/activate you can create venv using this command python3 -m venv venv

thank you. i appreciate it.

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