python将软件包和所有的依赖都下载到本地的目录?
实现这个功能,只需2步
一、下载
1、创建目录
目录用于存放包及其依赖
mkdir /root/rdbtools
2、安装软件
这里安装 rdbtools python-lzf
重点: --download 参数
pip3 install --download="/root/rdbtools" rdbtools python-lzf
注意:这个环境可以联网!
并没真正的安装!(pip3 list 可验证!)
3、查看目录
命令执行完成,进入目录查看
所有的软件包和依赖都已经下载好了。
[root@centos7 rdbtools]# ls -ltr total 492 -rw-r--r-- 1 root root 31867 Dec 8 02:14 rdbtools-0.1.15.tar.gz -rw-r--r-- 1 root root 9282 Dec 8 02:14 python-lzf-0.2.4.tar.gz -rw-r--r-- 1 root root 248704 Dec 8 02:14 redis-4.3.5-py3-none-any.whl -rw-r--r-- 1 root root 5763 Dec 8 02:14 async_timeout-4.0.2-py3-none-any.whl -rw-r--r-- 1 root root 40750 Dec 8 02:14 packaging-21.3-py3-none-any.whl -rw-r--r-- 1 root root 26844 Dec 8 02:14 typing_extensions-4.1.1-py3-none-any.whl -rw-r--r-- 1 root root 17978 Dec 8 02:14 importlib_metadata-4.8.3-py3-none-any.whl -rw-r--r-- 1 root root 98338 Dec 8 02:14 pyparsing-3.0.9-py3-none-any.whl -rw-r--r-- 1 root root 5313 Dec 8 02:14 zipp-3.6.0-py3-none-any.whl [root@centos7 rdbtools]#
# 打包
cd ..
zip -r rdbtools.zip rdbtools
下载好,之后,如何在其他的主机上进行安装?
二、离线安装
1、上传软件及依赖包
解压
[root@centos7 ~]# ls -l rdbtools.zip -rw-r--r-- 1 root root 476530 Dec 8 02:25 rdbtools.zip [root@centos7 ~]# unzip rdbtools.zip
2、本地安装
cd rdbtools/ pip3 install --no-index --find-links=./ rdbtools python-lzf
完成安装
[root@centos7 rdbtools]# pip3 install --no-index --find-links=./ rdbtools python-lzf WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead. Collecting rdbtools Collecting python-lzf Collecting redis (from rdbtools) Collecting packaging>=20.4 (from redis->rdbtools) Collecting typing-extensions; python_version < "3.8" (from redis->rdbtools) Collecting async-timeout>=4.0.2 (from redis->rdbtools) Collecting importlib-metadata>=1.0; python_version < "3.8" (from redis->rdbtools) Collecting pyparsing!=3.0.5,>=2.0.2 (from packaging>=20.4->redis->rdbtools) Collecting zipp>=0.5 (from importlib-metadata>=1.0; python_version < "3.8"->redis->rdbtools) Installing collected packages: pyparsing, packaging, typing-extensions, async-timeout, zipp, importlib-metadata, redis, rdbtools, python-lzf Running setup.py install for rdbtools ... done Running setup.py install for python-lzf ... done Successfully installed async-timeout-4.0.2 importlib-metadata-4.8.3 packaging-21.3 pyparsing-3.0.9 python-lzf-0.2.4 rdbtools-0.1.15 redis-4.3.5 typing-extensions-4.1.1 zipp-3.6.0
3、查看安装的包
[root@centos7 rdbtools]# pip3 list DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. async-timeout (4.0.2) importlib-metadata (4.8.3) packaging (21.3) pip (9.0.3) pyparsing (3.0.9) python-lzf (0.2.4) rdbtools (0.1.15) redis (4.3.5) setuptools (39.2.0) typing-extensions (4.1.1) zipp (3.6.0)