The usual solution to this problem in the Python world is to use virtualenvs or, even better, a wrapper like pipenv. If you install pipenv, you should be able to create a new virtualenv with a simple pipenv install
:
[user@host Foo]$ pipenv install
Creating a virtualenv for this
project… ⠋Using base prefix '/usr' New python executable in
/home/user/.local/share/virtualenvs/Foo-oXnKEj-P/bin/python3 Also
creating executable in
/home/user/.local/share/virtualenvs/Foo-oXnKEj-P/bin/python Installing
setuptools, pip, wheel...done.
Virtualenv location: /home/user/.local/share/virtualenvs/Foo-oXnKEj-P
Creating a Pipfile for this project… Pipfile.lock not found, creating…
Locking [dev-packages] dependencies… Locking [packages] dependencies…
Updated Pipfile.lock (c23e27)! Installing dependencies from
Pipfile.lock (c23e27)… �� ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 —
00:00:00 To activate this project's virtualenv, run the following: $
pipenv shell
Then enter the virtualenv with pipenv shell
[user@host Foo]$ pipenv shell
Spawning environment shell
(/bin/bash). Use 'exit' to leave. source
/home/user/.local/share/virtualenvs/Foo-oXnKEj-P/bin/activate
[user@host Foo]$ source /home/user/.local/share/virtualenvs/Foo-oXnKEj-P/bin/activate
Finally, you can install the packages in your requirements.txt:
(Foo-oXnKEj-P) [user@host Foo]$ pip install -r requirements.txt
Collecting Django==2.0.4 (from -r requirements.txt (line 1)) Using
cached
https://files.pythonhosted.org/packages/89/f9/94c20658f0cdecc2b6607811e2c0bb042408a51f589e5ad0cb0eac3236a1/Django-2.0.4-py3-none-any.whl
Collecting pytz (from Django==2.0.4->-r requirements.txt (line 1))
Using cached
https://files.pythonhosted.org/packages/dc/83/15f7833b70d3e067ca91467ca245bae0f6fe56ddc7451aa0dc5606b120f2/pytz-2018.4-py2.py3-none-any.whl
Installing collected packages: pytz, Django Successfully installed
Django-2.0.4 pytz-2018.4
(Foo-oXnKEj-P) [user@host Foo]$