0

How should i install a package inside a venv using sudo apt-get install? If i use sudo then the package will be installed globally and not only inside the venv, if i don't use sudo i will have no permission to install it because i am not root and get some error like this:

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? 

How can i install a package if it is not included in pip? What is the solution?

2
  • apt does not know about virtual environments. You need to use pip instead. Commented Oct 8, 2016 at 19:50
  • And what if a package is not installable via pip? Commented Oct 8, 2016 at 19:58

1 Answer 1

1

Virtualenv is meant to create localized python environments. Thus, it can only control python software packages via pip (or setuptools, etc). Apt installs software for the entire system and is separate from virtualenv.

If you are looking to install software from apt without sudo, I'd suggest you compile the software yourself and install it to your local home directory. For most packages, this is relatively straightforward (There are some software packages that will not work well when installed into your home directory).

Google "apt-get without sudo" for more instructions.

Sign up to request clarification or add additional context in comments.

Comments