当前位置:   article > 正文

python第三方库的下载安装,怎么下载python第三方库_python下载第三方库

python下载第三方库

大家好,小编来为大家解答以下问题,python如何下载第三方库numpy,python第三方库的下载安装,今天让我们一起来看看吧!

Source code download: 本文相关源码

1、场景介绍

在一些服务器上,我们搭建完Python环境之后,因为服务器的网络限制原因,不能直接通过pip命令下载安装Python的依赖包。
因此,我们需要在可以正常上网的服务器上下载好所需的依赖包文件,然后拷贝到目标服务器,通过pip在目标服务器上进行安装python自学清单

2、准备requirements.txt文件

requirements.txt文件罗列的是依赖包列表,表示你要下载的依赖包以及对应的版本。
该文件可以通过两种方式创建,分别是pip命令创建和手工创建。

在这里插入图片描述

  1. jupyter==1.0.0
  2. notebook==6.1.0

(1)pip命令创建requirements.txt,可以把当前服务器的Python依赖包生成列表到requirements.txt文件中。
【pip list】
【pip freeze >requirements.txt】

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

(2)手工创建requirements.txt,直接新建一个requirements.txt文件,然后按照格式填写所需依赖包以及对应版本号。

在这里插入图片描述

3、下载依赖包

注意:该步骤需要在可以正常上网的服务器上下载。下载的依赖包文件如图2所示。

pip download -r requirements.txt -d packages/ -i https://pypi.tuna.tsinghua.edu.cn/simple

其中:(packages/是要生成的文件夹,存放下载的依赖包文件;https://pypi.tuna.tsinghua.edu.cn/simple是镜像源地址)。

在这里插入图片描述

4、安装依赖包

准备好依赖包之后,就可以在无法使用pip命令下载安装依赖包的目标服务器上进行安装了。
使用命令之前,需要把packsges文件夹、requirements.txt文件拷贝到目标服务器,下面以requests依赖包为例。

pip install --no-index --find-links=./packages -r ./requirements.txt

(其中:./packsges是依赖包的所在路径;./requirements.txt是依赖包的列表路径)。

在这里插入图片描述

  1. D:\zjj\pip>pip list
  2. Package Version
  3. --------------------------------- ---------
  4. anyio 3.7.1
  5. argon2-cffi 21.3.0
  6. argon2-cffi-bindings 21.2.0
  7. arrow 1.2.3
  8. asttokens 2.2.1
  9. async-lru 2.0.4
  10. attrs 23.1.0
  11. Babel 2.12.1
  12. backcall 0.2.0
  13. beautifulsoup4 4.12.2
  14. bleach 6.0.0
  15. certifi 2023.7.22
  16. cffi 1.15.1
  17. charset-normalizer 3.2.0
  18. colorama 0.4.6
  19. comm 0.1.3
  20. debugpy 1.6.7
  21. decorator 5.1.1
  22. defusedxml 0.7.1
  23. distlib 0.3.7
  24. exceptiongroup 1.1.2
  25. executing 1.2.0
  26. fastjsonschema 2.18.0
  27. filelock 3.12.2
  28. fqdn 1.5.1
  29. idna 3.4
  30. importlib-metadata 6.8.0
  31. importlib-resources 6.0.0
  32. ipykernel 6.25.0
  33. ipython 8.12.2
  34. ipython-genutils 0.2.0
  35. ipywidgets 8.0.7
  36. isoduration 20.11.0
  37. jedi 0.19.0
  38. Jinja2 3.1.2
  39. json5 0.9.14
  40. jsonpointer 2.4
  41. jsonschema 4.18.4
  42. jsonschema-specifications 2023.7.1
  43. jupyter_client 8.3.0
  44. jupyter-console 6.6.3
  45. jupyter-contrib-core 0.4.2
  46. jupyter_core 5.3.1
  47. jupyter-events 0.6.3
  48. jupyter-highlight-selected-word 0.2.0
  49. jupyter-lsp 2.2.0
  50. jupyter-nbextensions-configurator 0.6.3
  51. jupyter_server 2.7.0
  52. jupyter_server_terminals 0.4.4
  53. jupyterlab 4.0.3
  54. jupyterlab-pygments 0.2.2
  55. jupyterlab_server 2.24.0
  56. jupyterlab-widgets 3.0.8
  57. lxml 4.9.3
  58. MarkupSafe 2.1.3
  59. matplotlib-inline 0.1.6
  60. mistune 3.0.1
  61. nbclient 0.8.0
  62. nbconvert 7.7.3
  63. nbformat 5.9.1
  64. nest-asyncio 1.5.7
  65. notebook 7.0.0
  66. notebook_shim 0.2.3
  67. overrides 7.3.1
  68. packaging 23.1
  69. pandocfilters 1.5.0
  70. parso 0.8.3
  71. pickleshare 0.7.5
  72. pip 23.2.1
  73. pipenv 2023.7.23
  74. pkgutil_resolve_name 1.3.10
  75. platformdirs 3.10.0
  76. prometheus-client 0.17.1
  77. prompt-toolkit 3.0.39
  78. psutil 5.9.5
  79. pure-eval 0.2.2
  80. pycparser 2.21
  81. Pygments 2.15.1
  82. python-dateutil 2.8.2
  83. python-json-logger 2.0.7
  84. pytz 2023.3
  85. pywin32 306
  86. pywinpty 2.0.11
  87. PyYAML 6.0.1
  88. pyzmq 25.1.0
  89. qtconsole 5.4.3
  90. QtPy 2.3.1
  91. referencing 0.30.0
  92. requests 2.31.0
  93. rfc3339-validator 0.1.4
  94. rfc3986-validator 0.1.1
  95. rpds-py 0.9.2
  96. Send2Trash 1.8.2
  97. setuptools 68.0.0
  98. six 1.16.0
  99. sniffio 1.3.0
  100. soupsieve 2.4.1
  101. stack-data 0.6.2
  102. terminado 0.17.1
  103. tinycss2 1.2.1
  104. tomli 2.0.1
  105. tornado 6.3.2
  106. traitlets 5.9.0
  107. typing_extensions 4.7.1
  108. uri-template 1.3.0
  109. urllib3 2.0.4
  110. virtualenv 20.24.2
  111. virtualenv-clone 0.5.7
  112. wcwidth 0.2.6
  113. webcolors 1.13
  114. webencodings 0.5.1
  115. websocket-client 1.6.1
  116. widgetsnbextension 4.0.8
  117. zipp 3.16.2
  118. D:\zjj\pip>pip install --no-index --find-links=./packages -r ./requirements.txt
  119. Looking in links: ./packages
  120. Processing d:\zjj\pip\packages\requests-2.28.2-py3-none-any.whl (from -r ./requirements.txt (line 1))
  121. Requirement already satisfied: charset-normalizer<4,>=2 in d:\environment\python\python3.8.10\lib\site-packages (from requests==2.28.2->-r ./requirements.txt (line 1)) (3.2.0)
  122. Requirement already satisfied: idna<4,>=2.5 in d:\environment\python\python3.8.10\lib\site-packages (from requests==2.28.2->-r ./requirements.txt (line 1)) (3.4)
  123. Processing d:\zjj\pip\packages\urllib3-1.26.16-py2.py3-none-any.whl (from requests==2.28.2->-r ./requirements.txt (line 1))
  124. Requirement already satisfied: certifi>=2017.4.17 in d:\environment\python\python3.8.10\lib\site-packages (from requests==2.28.2->-r ./requirements.txt (line 1)) (2023.7.22)
  125. Installing collected packages: urllib3, requests
  126. Attempting uninstall: urllib3
  127. Found existing installation: urllib3 2.0.4
  128. Uninstalling urllib3-2.0.4:
  129. Successfully uninstalled urllib3-2.0.4
  130. Attempting uninstall: requests
  131. Found existing installation: requests 2.31.0
  132. Uninstalling requests-2.31.0:
  133. Successfully uninstalled requests-2.31.0
  134. Successfully installed requests-2.28.2 urllib3-1.26.16
  135. D:\zjj\pip>pip list
  136. Package Version
  137. --------------------------------- ---------
  138. anyio 3.7.1
  139. argon2-cffi 21.3.0
  140. argon2-cffi-bindings 21.2.0
  141. arrow 1.2.3
  142. asttokens 2.2.1
  143. async-lru 2.0.4
  144. attrs 23.1.0
  145. Babel 2.12.1
  146. backcall 0.2.0
  147. beautifulsoup4 4.12.2
  148. bleach 6.0.0
  149. certifi 2023.7.22
  150. cffi 1.15.1
  151. charset-normalizer 3.2.0
  152. colorama 0.4.6
  153. comm 0.1.3
  154. debugpy 1.6.7
  155. decorator 5.1.1
  156. defusedxml 0.7.1
  157. distlib 0.3.7
  158. exceptiongroup 1.1.2
  159. executing 1.2.0
  160. fastjsonschema 2.18.0
  161. filelock 3.12.2
  162. fqdn 1.5.1
  163. idna 3.4
  164. importlib-metadata 6.8.0
  165. importlib-resources 6.0.0
  166. ipykernel 6.25.0
  167. ipython 8.12.2
  168. ipython-genutils 0.2.0
  169. ipywidgets 8.0.7
  170. isoduration 20.11.0
  171. jedi 0.19.0
  172. Jinja2 3.1.2
  173. json5 0.9.14
  174. jsonpointer 2.4
  175. jsonschema 4.18.4
  176. jsonschema-specifications 2023.7.1
  177. jupyter_client 8.3.0
  178. jupyter-console 6.6.3
  179. jupyter-contrib-core 0.4.2
  180. jupyter_core 5.3.1
  181. jupyter-events 0.6.3
  182. jupyter-highlight-selected-word 0.2.0
  183. jupyter-lsp 2.2.0
  184. jupyter-nbextensions-configurator 0.6.3
  185. jupyter_server 2.7.0
  186. jupyter_server_terminals 0.4.4
  187. jupyterlab 4.0.3
  188. jupyterlab-pygments 0.2.2
  189. jupyterlab_server 2.24.0
  190. jupyterlab-widgets 3.0.8
  191. lxml 4.9.3
  192. MarkupSafe 2.1.3
  193. matplotlib-inline 0.1.6
  194. mistune 3.0.1
  195. nbclient 0.8.0
  196. nbconvert 7.7.3
  197. nbformat 5.9.1
  198. nest-asyncio 1.5.7
  199. notebook 7.0.0
  200. notebook_shim 0.2.3
  201. overrides 7.3.1
  202. packaging 23.1
  203. pandocfilters 1.5.0
  204. parso 0.8.3
  205. pickleshare 0.7.5
  206. pip 23.2.1
  207. pipenv 2023.7.23
  208. pkgutil_resolve_name 1.3.10
  209. platformdirs 3.10.0
  210. prometheus-client 0.17.1
  211. prompt-toolkit 3.0.39
  212. psutil 5.9.5
  213. pure-eval 0.2.2
  214. pycparser 2.21
  215. Pygments 2.15.1
  216. python-dateutil 2.8.2
  217. python-json-logger 2.0.7
  218. pytz 2023.3
  219. pywin32 306
  220. pywinpty 2.0.11
  221. PyYAML 6.0.1
  222. pyzmq 25.1.0
  223. qtconsole 5.4.3
  224. QtPy 2.3.1
  225. referencing 0.30.0
  226. requests 2.28.2
  227. rfc3339-validator 0.1.4
  228. rfc3986-validator 0.1.1
  229. rpds-py 0.9.2
  230. Send2Trash 1.8.2
  231. setuptools 68.0.0
  232. six 1.16.0
  233. sniffio 1.3.0
  234. soupsieve 2.4.1
  235. stack-data 0.6.2
  236. terminado 0.17.1
  237. tinycss2 1.2.1
  238. tomli 2.0.1
  239. tornado 6.3.2
  240. traitlets 5.9.0
  241. typing_extensions 4.7.1
  242. uri-template 1.3.0
  243. urllib3 1.26.16
  244. virtualenv 20.24.2
  245. virtualenv-clone 0.5.7
  246. wcwidth 0.2.6
  247. webcolors 1.13
  248. webencodings 0.5.1
  249. websocket-client 1.6.1
  250. widgetsnbextension 4.0.8
  251. zipp 3.16.2
  252. D:\zjj\pip>
文章知识点与官方知识档案匹配,可进一步学习相关知识
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/1010839
推荐阅读
相关标签
  

闽ICP备14008679号