-1

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?

  • "*Is this meant i do not have access to run sudo command?*" I mean, that's almost exactly what it says. You need to include *all* pertinent information here, including the full stack trace of the error you get when attempting to run the command you provided. – esqew Jan 11 '21 at 14:53
  • 4
    if I'm not totally mistaken venv shouldn't require sudo. Did you check that you have rights for creating a "env" folder? Missing write permissions seem the most likely case too me – Raphael Jan 11 '21 at 14:54
  • 1
    As a user on a Linux machine, you should have access to your own home directory (try `cd ~` to go there). Within this directory you should have adequate permissions to create files and sub-directories, including a python virtual environment. If you do not, then contact your system administrator. – h0r53 Jan 11 '21 at 14:56

2 Answers2

2

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.

user2314737
  • 27,088
  • 20
  • 102
  • 114
1

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.

Raphael
  • 1,731
  • 2
  • 7
  • 23