我不得不在一个没有互联网接入的公司服务器上安装Django。下载并安装 * pytz-2023.3.post1-py2.py3-none-any.whl* 后,我可以从.zip文件安装 django。
你可能会问如果我能安装它有什么意义?好吧,我可以从下载的文件安装django和必要的库,只有当服务器连接到互联网。
事实证明,在安装过程中需要以下库:- asgiref-3.7.2-py3-none-any.whl - tzdata-2023.3-py2.py3-none-any.whl - sqlparse-0.4.4-py3-none-any.whl
当然,我下载并安装它们没有任何问题。然而,我在安装Django时仍然会遇到一个错误。
下面是错误代码。
C:\Users\Administrator\Downloads>py -m pip install django-stable-4.2.x.zip
Processing c:\users\administrator\downloads\django-stable-4.2.x.zip
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [7 lines of output]
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000221F9E73C10>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000221F9E7B4D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000221F9E84250>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000221F9E84D90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000221F9E857D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/
ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)
ERROR: No matching distribution found for setuptools>=40.8.0
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
安装将在步骤 * 安装构建依赖项时停止.错误***
当我将服务器连接到Internet时,安装正确进行。这可能意味着正在从Internet下载其他内容。
对于离线测试,我使用安装在VirtualBox上的服务器,因此可以随时访问互联网。公司服务器上没有这个选项。
请告诉我如何在服务器上离线安装djano而不会出现上述错误。
谢谢你的任何帮助和建议
1条答案
按热度按时间flvlnr441#
您需要下载依赖项并将其安装在脱机系统上,您需要在可以访问Internet的系统上创建requirements.txt
pip freeze > requirements.txt
然后你应该下载依赖在一个目录:
pip download -r requirements.txt -d path_to_the_directory
将requirements.txt复制到目录
将目录移动到脱机服务器,然后安装软件包:
pip install -r path_to_the_directory/requirements.txt --no-index --find-links path_to_the_directory
我希望这对你有帮助。