如果在线安装, pip install django-axes,很容易
但在内网环境,没那么容易,
根据以前的经验, 下载tar.gz 安装
参考我前一篇:https://www.cnblogs.com/lxgbky/p/12932104.html
但这次,用上面方法不行,因为axes这个包,还有关联的其他app, 离线安装时,内部默认联网下载其他包,所以失败。失败信息如下:
这次,我在可以上网的电脑上,把相关包下载下来
pip download django-axes -d ./aaa
(py3.6env) lxg@lxg-opt:~/98receive/pystudy/general1$ pip download django-axes -d ./aaa Collecting django-axes Downloading django_axes-5.20.0-py3-none-any.whl (53 kB) |████████████████████████████████| 53 kB 102 kB/s Saved ./aaa/django_axes-5.20.0-py3-none-any.whl Collecting django>=2.2 Using cached Django-3.2.4-py3-none-any.whl (7.9 MB) Saved ./aaa/Django-3.2.4-py3-none-any.whl Collecting django-ipware<4,>=3 Using cached django-ipware-3.0.2.tar.gz (9.0 kB) Saved ./aaa/django-ipware-3.0.2.tar.gz Collecting asgiref<4,>=3.3.2
下载结果:
然后复制到内网机器
一点一点安装,先安装相关依赖,最后安装 django-axes,最后居然成功了
(py368) [root@localhost emic]# pip install asgiref-3.3.4-py3-none-any.whl Processing ./asgiref-3.3.4-py3-none-any.whl Requirement already satisfied: typing-extensions; python_version < "3.8" in /data/env/py368/lib/python3.6/site-packages (from asgiref==3.3.4) (3.7.4.1) Installing collected packages: asgiref Successfully installed asgiref-3.3.4 (py368) [root@localhost emic]# (py368) [root@localhost emic]# pip install pytz-2021.1-py2.py3-none-any.whl Processing ./pytz-2021.1-py2.py3-none-any.whl ERROR: django-stubs 1.5.0 has requirement mypy<0.780,>=0.770, but you'll have mypy 0.720 which is incompatible. Installing collected packages: pytz Attempting uninstall: pytz Found existing installation: pytz 2019.1 Uninstalling pytz-2019.1: Successfully uninstalled pytz-2019.1 Successfully installed pytz-2021.1 (py368) [root@localhost emic]# (py368) [root@localhost emic]# pip install typing_extensions-3.10.0.0-py3-none-any.whl Processing ./typing_extensions-3.10.0.0-py3-none-any.whl ERROR: django-stubs 1.5.0 has requirement mypy<0.780,>=0.770, but you'll have mypy 0.720 which is incompatible. Installing collected packages: typing-extensions Attempting uninstall: typing-extensions Found existing installation: typing-extensions 3.7.4.1 Uninstalling typing-extensions-3.7.4.1: Successfully uninstalled typing-extensions-3.7.4.1 Successfully installed typing-extensions-3.10.0.0 (py368) [root@localhost emic]# pip install sqlparse-0.4.1-py3-none-any.whl Processing ./sqlparse-0.4.1-py3-none-any.whl ERROR: django-stubs 1.5.0 has requirement mypy<0.780,>=0.770, but you'll have mypy 0.720 which is incompatible. Installing collected packages: sqlparse Attempting uninstall: sqlparse Found existing installation: sqlparse 0.3.0 Uninstalling sqlparse-0.3.0: Successfully uninstalled sqlparse-0.3.0 Successfully installed sqlparse-0.4.1 (py368) [root@localhost emic]# pip install django-ipware-3.0.2.tar.gz Processing ./django-ipware-3.0.2.tar.gz Building wheels for collected packages: django-ipware Building wheel for django-ipware (setup.py) ... done Created wheel for django-ipware: filename=django_ipware-3.0.2-py2.py3-none-any.whl size=9336 sha256=ea737403b4fb9c7875699b7634e0346625bb803184717c948f8c04c0fe8c601a Stored in directory: /root/.cache/pip/wheels/70/1b/c0/7ade9431c50d055ea10142a8cff941b3840df353b7eaa6dd93 Successfully built django-ipware Installing collected packages: django-ipware Successfully installed django-ipware-3.0.2 (py368) [root@localhost emic]# pip install django-axes-5.19.0 注意,这样直接安装注定失败,因为走互联网 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fbe840fe400>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/django-axes-5-19-0/ ^Z [6]+ Stopped pip install django-axes-5.19.0 (py368) [root@localhost emic]# pip install django_axes-5.19.0-py3-none-any.whl 这个是成功的,这个是用下载的文件 Processing ./django_axes-5.19.0-py3-none-any.whl Requirement already satisfied: django>=2.2 in /data/env/py368/lib/python3.6/site-packages (from django-axes==5.19.0) (2.2.2) Requirement already satisfied: django-ipware<4,>=3 in /data/env/py368/lib/python3.6/site-packages (from django-axes==5.19.0) (3.0.2) Requirement already satisfied: sqlparse in /data/env/py368/lib/python3.6/site-packages (from django>=2.2->django-axes==5.19.0) (0.4.1) Requirement already satisfied: pytz in /data/env/py368/lib/python3.6/site-packages (from django>=2.2->django-axes==5.19.0) (2021.1) Installing collected packages: django-axes Successfully installed django-axes-5.19.0 看到成功信息,很开心