Skip to content
Advertisement

Problem installing django on a virtual machine with no access to pypi.org


I developed a relatively simple site with Django and I need to deploy it on a Windows VM hosted on a PC on the local network. These are the requirements:
requirements.txt

asgiref==3.5.0
autopep8==1.6.0
Django==4.0.3
Pillow==9.0.1
pycodestyle==2.8.0
sqlparse==0.4.2
toml==0.10.2
tzdata==2022.1

Having no access to the internet, I followed these steps:
PC With Internet

mkdir dependencies
pip download -r requirements.txt -d "./dependencies"
tar cvfz dependencies.tar.gz dependencies

I then moved the tar file on the VM and did the following:

tar zxvf dependencies.tar.gz
cd dependencies
for %x in (dir *.whl) do pip install %x --no-index --force-reinstall

The above commands resulted in this pip freeze:

asgiref @ file:///C:/website/packages/dependencies/asgiref-3.5.0-py3-none-any.whl
Pillow @ file:///C:/website/packages/dependencies/Pillow-9.0.1-cp310-cp310-win_amd64.whl
pycodestyle @ file:///C:/website/packages/dependencies/pycodestyle-2.8.0-py2.py3-none-any.whl
sqlparse @ file:///C:/website/packages/dependencies/sqlparse-0.4.2-py3-none-any.whl
toml @ file:///C:/website/packages/dependencies/toml-0.10.2-py2.py3-none-any.whl
tzdata @ file:///C:/website/packages/dependencies/tzdata-2022.1-py2.py3-none-any.whl

As you can see Django and autopep8 fail to install even though the requirements should be met. What am I missing?

Any help pointing me to the solution would be very much appreciated!!

Thanks

BTW, this is the log:

(django_venv) C:websitepackagesdependencies>pip install dir --no-index --force-reinstall
ERROR: Could not find a version that satisfies the requirement dir (from versions: none)
ERROR: No matching distribution found for dir

(django_venv) C:websitepackagesdependencies>pip install asgiref-3.5.0-py3-none-any.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciesasgiref-3.5.0-py3-none-any.whl
Installing collected packages: asgiref
  Attempting uninstall: asgiref
    Found existing installation: asgiref 3.5.0
    Uninstalling asgiref-3.5.0:
      Successfully uninstalled asgiref-3.5.0
Successfully installed asgiref-3.5.0

(django_venv) C:websitepackagesdependencies>pip install autopep8-1.6.0-py2.py3-none-any.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciesautopep8-1.6.0-py2.py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement toml (from autopep8) (from versions: none)
ERROR: No matching distribution found for toml

(django_venv) C:websitepackagesdependencies>pip install Django-4.0.3-py3-none-any.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciesdjango-4.0.3-py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement tzdata; sys_platform == "win32" (from django) (from versions: none)
ERROR: No matching distribution found for tzdata; sys_platform == "win32"

(django_venv) C:websitepackagesdependencies>pip install Pillow-9.0.1-cp310-cp310-win_amd64.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciespillow-9.0.1-cp310-cp310-win_amd64.whl
Installing collected packages: Pillow
  Attempting uninstall: Pillow
    Found existing installation: Pillow 9.0.1
    Uninstalling Pillow-9.0.1:
      Successfully uninstalled Pillow-9.0.1
Successfully installed Pillow-9.0.1

(django_venv) C:websitepackagesdependencies>pip install pycodestyle-2.8.0-py2.py3-none-any.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciespycodestyle-2.8.0-py2.py3-none-any.whl
Installing collected packages: pycodestyle
  Attempting uninstall: pycodestyle
    Found existing installation: pycodestyle 2.8.0
    Uninstalling pycodestyle-2.8.0:
      Successfully uninstalled pycodestyle-2.8.0
Successfully installed pycodestyle-2.8.0

(django_venv) C:websitepackagesdependencies>pip install sqlparse-0.4.2-py3-none-any.whl --no-index --force-reinstall 
Processing c:websitepackagesdependenciessqlparse-0.4.2-py3-none-any.whl
Installing collected packages: sqlparse
  Attempting uninstall: sqlparse
    Found existing installation: sqlparse 0.4.2
    Uninstalling sqlparse-0.4.2:
      Successfully uninstalled sqlparse-0.4.2
Successfully installed sqlparse-0.4.2

(django_venv) C:websitepackagesdependencies>pip install toml-0.10.2-py2.py3-none-any.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciestoml-0.10.2-py2.py3-none-any.whl
Installing collected packages: toml
  Attempting uninstall: toml
    Found existing installation: toml 0.10.2
    Uninstalling toml-0.10.2:
      Successfully uninstalled toml-0.10.2
Successfully installed toml-0.10.2

(django_venv) C:websitepackagesdependencies>pip install tzdata-2022.1-py2.py3-none-any.whl --no-index --force-reinstall
Processing c:websitepackagesdependenciestzdata-2022.1-py2.py3-none-any.whl
Installing collected packages: tzdata
  Attempting uninstall: tzdata
    Found existing installation: tzdata 2022.1
    Uninstalling tzdata-2022.1:
      Successfully uninstalled tzdata-2022.1
Successfully installed tzdata-2022.1

Advertisement

Answer

After unpacking the archive in the vm, use the --find-links option.

pip install  -r requirements.txt -f ./dependencies --no-index
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement