1

I was in venv in Ubuntu 14.04, and before I thought it over, I used the sudo apt-get upgrade command while in venv. Now I want to know if it is a true upgrade of my virtualenv or not and do I need to fix it?

2
  • You mean sudo apt-get upgrade?
    – Byte Commander
    Oct 2, 2016 at 19:08
  • This depends on whether you have created the virtualenv using the --system-site-packages option.
    – edwinksl
    Oct 2, 2016 at 19:20

2 Answers 2

2

A Python Virtual Environment ("venv") does not affect applications unrelated to Python.

It only adds the bin/ directory of the venv which contains its executables to the front of your PATH variable. This causes a command look-up for e.g. python to resolve to that instead of the system's executable. Additionally it changes some other environment variables and aliases used by Python.

None of these changes should break apt-get and it's impossible that they affect the way how system packages are managed.

To conclude, it is safe to run apt-get or similar stuff while operating in a Python Virtual Environment.

If you want, you can examine the bin/activate script in your venv's directory which you use to enter the virtual environment. That way you can see exactly what gets changed.

1

Yes only if you have created the virtualenv using the --system-site-packages option.

Running sudo apt-get upgrade upgrades system Python packages (prefixed with python- for Python 2 packages and python3- for Python 3 packages) that you have previously installed using apt-get. If your virtualenv is created using the --system-site-packages option, then it uses the system Python packages and does not have its own site packages. In this case, sudo apt-get upgrade upgrades your virtualenv in the sense that the system Python packages it uses are upgraded.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .