I am in a virtual environment which shares the system site packages (created with venv
in Python 3.5), and I would like to install all packages in a given requirements.txt into this venv. The system-wide python installation is read-only, so I cannot modify it.
Now, for example, my requirements.txt lists, among many others,
SomePackage==2.0
as requirement, while the system installation already contains SomePackage-1.0
. Pip thus tries to uninstall SomePackage-1.0
to upgrade to version 2.0. This, however, fails because the system-wide python installation is read-only.
Is there a way to run pip install -r requirements.txt
in a way that ignores installed packages if they have a different version from the required one and just installs the required version into the venv?
I guess this would be similar to installing each package one by one and using --ignore-installed
whenever the package is already present in a different version than the required one. This, however, seems quite cumbersome. Is there a better way?
Note that I am using a venv with shared system site packages because I want to avoid the installation of several huge packages each time I create a new venv. Thus I do not want to switch to a fully isolated venv, which would, of course, not have the above issue.
Any hint would be greatly appreciated! Thanks a lot!