creating python virtual env on Linux

Question:

I’m new to Linux environment where i need to create a virtual environment for my project. As this is a development machine i will not have access like i used to have in my own machine. I tried running the below commands :

    python3 -m venv env 

But got permission denied:

I tried using sudo su command upon which it asked to enter my password. Later it said "Sorry, user xxxx is not allowed to execute ‘usr/bin/su’ as root on

Is this meant i do not have access to run sudo command?

Asked By: viswanath thatha

||

Answers:

if you run python3 -m venv env a virtual environment will be created in your current directory. As venv does not require admin privileges it seems more likely that you are trying to run the command in a directory where you don’t have sufficient write permissions.

Answered By: Raphael

The "permission denied" error is probably due to the fact that you are in a directory where you have no write rights

Solution:

  1. either change directory (for instance with cd, this will take you to your $HOME where you certainly have write rights)

or

  1. give a full path for directory where you want to save the virtual environment (for instance to save in ~/my_env use python3 -m venv ~/my_env)

By issuing the command

python -m venv -h

you can see all the options of venv.

Answered By: user2314737
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.