python中使用什么命令安装组件_在离线环境下安装python组件

在一些项目中,我们会不可避免地使用到python组件,而生产环境大多数服务器是没有办法直接联网下载python的包的。当然,有的小伙伴会很聪明地把这个包的whl下载下来到服务器上去执行,但是会得到这样的结果:

C:\Users\a-mengsr>pip install C:\Users\a-mengsr\Desktop\mssql_scripter-1.0.0a23-py2.py3-none-win32.whl

Processing c:\users\a-mengsr\desktop\mssql_scripter-1.0.0a23-py2.py3-none-win32.whl

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.org timed out. (connecttimeout=15)')': /simple/future/

WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/future/

可以看到,即便是指定离线的whl包,pip安装过程中同样会去尝试联网,因为python的包是存在依赖的,当在本地环境找不到依赖时,就会尝试进行下载。

遇到这种情况,可以通过如下方式解决:

1、首先在一台可以上网的电脑上,完成组件安装的整个过程,并记录下输出的日志:

C:\Windows\system32>pip install mssql-scripter --proxy=proxyhk.aac.com:8011

Collecting mssql-scripter

Downloading mssql_scripter-1.0.0a23-py2.py3-none-win32.whl (36.3 MB)

|████████████████████████████████| 36.3 MB 123 kB/s

Collecting future>=0.16.0

Downloading future-0.18.2.tar.gz (829 kB)

|████████████████████████████████| 829 kB 3.3 MB/s

Collecting wheel>=0.29.0

Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB)

Collecting enum34>=1.1.6

Downloading enum34-1.1.10-py3-none-any.whl (11 kB)

Using legacy setup.py install for future, since package 'wheel' is not installed.

Installing collected packages: future, wheel, enum34, mssql-scripter

Running setup.py install for future ... done

Successfully installed enum34-1.1.10 future-0.18.2 mssql-scripter-1.0.0a23 wheel-0.35.1

在这个过程中,会输出在安装过程中所使用到的依赖包。根据上述日志可以看到,在安装mssql-scripter这个组件的过程中,一共使用到了feature、wheel、enum34这三个额外的依赖。那么,首先前往https://pypi.org,搜索并按照平台下载对应的依赖包。

依赖包有可能是whl格式的文件,也有可能是tar.gz的源码。如果是whl格式的文件,直接使用如下命令进行安装:

C:\Users\a-mengsr>pip install C:\Users\a-mengsr\Desktop\wheel-0.35.1-py2.py3-none-any.whl

Processing c:\users\a-mengsr\desktop\wheel-0.35.1-py2.py3-none-any.whl

Installing collected packages: wheel

Successfully installed wheel-0.35.1

C:\Users\a-mengsr>pip install C:\Users\a-mengsr\Desktop\enum34-1.1.10-py3-none-any.whl

Processing c:\users\a-mengsr\desktop\enum34-1.1.10-py3-none-any.whl

Installing collected packages: enum34

Successfully installed enum34-1.1.10

而遇到源码类型的包,则直接解压缩,而后进入其目录,在命令行下执行指令,至于执行的指令,在上面的日志中已经给出来了:

setup.py install

因为是源码安装,这个过程中会执行编译,输出很多,此处省略。

而将上述所有依赖全部手动安装完毕之后,就可以重新安装上述的主whl了:

C:\Users\a-mengsr>pip install C:\Users\a-mengsr\Desktop\mssql_scripter-1.0.0a23-py2.py3-none-win32.whl

Processing c:\users\a-mengsr\desktop\mssql_scripter-1.0.0a23-py2.py3-none-win32.whl

Requirement already satisfied: future>=0.16.0 in d:\yinl\python3\lib\site-packages\future-0.18.2-py3.8.egg (from mssql-scripter==1.0.0a23) (0.18.2)

Requirement already satisfied: enum34>=1.1.6 in d:\yinl\python3\lib\site-packages (from mssql-scripter==1.0.0a23) (1.1.10)

Requirement already satisfied: wheel>=0.29.0 in d:\yinl\python3\lib\site-packages (from mssql-scripter==1.0.0a23) (0.35.1)

Installing collected packages: mssql-scripter

Successfully installed mssql-scripter-1.0.0a23

就可以完成安装了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Introduction to gettext Usually, programs are written and documented in English, and use English at execution time for interacting with users. This is true not only from within GNU, but also in a great deal of proprietary and free software. Using a common language is quite handy for communication between developers, maintainers and users from all countries. On the other hand, most people are less comfortable with English than with their own native language, and would rather be using their mother tongue for day to day's work, as far as possible. Many would simply love seeing their computer screen showing a lot less of English, and far more of their own language. GNU `gettext' is an important step for the GNU Translation Project, as it is an asset on which we may build many other steps. This package offers to programmers, translators, and even users, a well integrated set of tools and documentation. Specifically, the GNU `gettext' utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages. These tools include a set of conventions about how programs should be written to support message catalogs, a directory and file naming organization for the message catalogs themselves, a runtime library supporting the retrieval of translated messages, and a few stand-alone programs to massage in various ways the sets of translatable strings, or already translated strings. A special GNU Emacs mode also helps interested parties in preparing these sets, or bringing them up to date.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值