热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在Python3环境中实现离线模块安装的方法与技巧

在Python3环境中,当无法连接互联网时,可以通过下载离线模块包来实现模块的安装。具体步骤包括:首先从PyPI网站下载所需的模块包,然后将其传输到目标环境,并使用`pipinstall`命令进行本地安装。此方法不仅适用于单个模块,还支持依赖项的批量安装,确保开发环境的完整性和一致性。

说明:

  需要在环境中安装python的模块,但是无法联网,就通过在Pypi上下载离线模块的包进行安装

安装过程:

1.下载模块,如PyMySQL-0.9.3.tar.gz,下载地址:https://files.pythonhosted.org/packages/da/15/23ba6592920e21cb40eb0fe0ea002d2b6177beb1ca8a4c1add5a8f32754d/PyMySQL-0.9.3.tar.gz

2.上传至服务器,并解压缩

3.通过python命令执行安装

python3 setup.py install

安装日志:

[aiprd@hadoop3 PyMySQL-0.9.3]$ python3 setup.py install
running
install
running bdist_egg
running egg_info
writing PyMySQL.egg
-info/PKG-INFO
writing dependency_links to PyMySQL.egg
-info/dependency_links.txt
writing requirements to PyMySQL.egg
-info/requires.txt
writing top
-level names to PyMySQL.egg-info/top_level.txt
reading manifest
file 'PyMySQL.egg-info/SOURCES.txt'
reading manifest template
'MANIFEST.in'
writing manifest
file 'PyMySQL.egg-info/SOURCES.txt'
installing library code to build
/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build
/lib
creating build
/lib/pymysql
copying pymysql
/protocol.py -> build/lib/pymysql
copying pymysql
/connections.py -> build/lib/pymysql
copying pymysql
/err.py -> build/lib/pymysql
copying pymysql
/optionfile.py -> build/lib/pymysql
copying pymysql
/_socketio.py -> build/lib/pymysql
copying pymysql
/_compat.py -> build/lib/pymysql
copying pymysql
/__init__.py -> build/lib/pymysql
copying pymysql
/times.py -> build/lib/pymysql
copying pymysql
/cursors.py -> build/lib/pymysql
copying pymysql
/converters.py -> build/lib/pymysql
copying pymysql
/util.py -> build/lib/pymysql
copying pymysql
/charset.py -> build/lib/pymysql
copying pymysql
/_auth.py -> build/lib/pymysql
creating build
/lib/pymysql/constants
copying pymysql
/constants/CLIENT.py -> build/lib/pymysql/constants
copying pymysql
/constants/SERVER_STATUS.py -> build/lib/pymysql/constants
copying pymysql
/constants/CR.py -> build/lib/pymysql/constants
copying pymysql
/constants/FIELD_TYPE.py -> build/lib/pymysql/constants
copying pymysql
/constants/__init__.py -> build/lib/pymysql/constants
copying pymysql
/constants/FLAG.py -> build/lib/pymysql/constants
copying pymysql
/constants/COMMAND.py -> build/lib/pymysql/constants
copying pymysql
/constants/ER.py -> build/lib/pymysql/constants
creating build
/bdist.linux-x86_64
creating build
/bdist.linux-x86_64/egg
creating build
/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/protocol.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/connections.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/err.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/optionfile.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/_socketio.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/_compat.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/__init__.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/times.py -> build/bdist.linux-x86_64/egg/pymysql
creating build
/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/CLIENT.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/SERVER_STATUS.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/CR.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/FIELD_TYPE.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/__init__.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/FLAG.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/COMMAND.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/constants/ER.py -> build/bdist.linux-x86_64/egg/pymysql/constants
copying build
/lib/pymysql/cursors.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/converters.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/util.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/charset.py -> build/bdist.linux-x86_64/egg/pymysql
copying build
/lib/pymysql/_auth.py -> build/bdist.linux-x86_64/egg/pymysql
byte-compiling build/bdist.linux-x86_64/egg/pymysql/protocol.py to protocol.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/connections.py to connections.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/err.py to err.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/optionfile.py to optionfile.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/_socketio.py to _socketio.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/_compat.py to _compat.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/times.py to times.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/CLIENT.py to CLIENT.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/SERVER_STATUS.py to SERVER_STATUS.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/CR.py to CR.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/FIELD_TYPE.py to FIELD_TYPE.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/FLAG.py to FLAG.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/COMMAND.py to COMMAND.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/constants/ER.py to ER.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/cursors.py to cursors.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/converters.py to converters.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/util.py to util.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/charset.py to charset.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/pymysql/_auth.py to _auth.cpython-37.pyc
creating build
/bdist.linux-x86_64/egg/EGG-INFO
copying PyMySQL.egg
-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyMySQL.egg
-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyMySQL.egg
-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyMySQL.egg
-info/pbr.json -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyMySQL.egg
-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyMySQL.egg
-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating
'dist/PyMySQL-0.9.3-py3.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing
'build/bdist.linux-x86_64/egg' (and everything under it)
Processing PyMySQL
-0.9.3-py3.7.egg
Copying PyMySQL
-0.9.3-py3.7.egg to /home/aiprd/app/python-3.7.4/lib/python3.7/site-packages
Adding PyMySQL
0.9.3 to easy-install.pth fileInstalled /home/aiprd/app/python-3.7.4/lib/python3.7/site-packages/PyMySQL-0.9.3-py3.7.egg
Processing dependencies
for PyMySQL==0.9.3
Finished processing dependencies
for PyMySQL==0.9.3

 

4.查看模块信息

[aiprd@hadoop3 PyMySQL-0.9.3]$ pydoc3 modules | grep mysql
_testbuffer ftplib pymysql weakref

 

说明已经安装完成

 

文档创建时间:2019年8月26日15:32:54

转:https://www.cnblogs.com/chuanzhang053/p/11412858.html



推荐阅读
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 本文详细记录了在基于Debian的Deepin 20操作系统上安装MySQL 5.7的具体步骤,包括软件包的选择、依赖项的处理及远程访问权限的配置。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • CentOS7源码编译安装MySQL5.6
    2019独角兽企业重金招聘Python工程师标准一、先在cmake官网下个最新的cmake源码包cmake官网:https:www.cmake.org如此时最新 ... [详细]
  • 本题通过将每个矩形视为一个节点,根据其相对位置构建拓扑图,并利用深度优先搜索(DFS)或状态压缩动态规划(DP)求解最小涂色次数。本文详细解析了该问题的建模思路与算法实现。 ... [详细]
  • 深入理解Redis的数据结构与对象系统
    本文详细探讨了Redis中的数据结构和对象系统的实现,包括字符串、列表、集合、哈希表和有序集合等五种核心对象类型,以及它们所使用的底层数据结构。通过分析源码和相关文献,帮助读者更好地理解Redis的设计原理。 ... [详细]
  • 本文深入探讨了 Redis 的两种持久化方式——RDB 快照和 AOF 日志。详细介绍了它们的工作原理、配置方法以及各自的优缺点,帮助读者根据具体需求选择合适的持久化方案。 ... [详细]
  • Windows 7 64位系统下Redis的安装与PHP Redis扩展配置
    本文详细介绍了在Windows 7 64位操作系统中安装Redis以及配置PHP Redis扩展的方法,包括下载、安装和基本使用步骤。适合对Redis和PHP集成感兴趣的开发人员参考。 ... [详细]
  • PHP 编程疑难解析与知识点汇总
    本文详细解答了 PHP 编程中的常见问题,并提供了丰富的代码示例和解决方案,帮助开发者更好地理解和应用 PHP 知识。 ... [详细]
  • 网易严选Java开发面试:MySQL索引深度解析
    本文详细记录了网易严选Java开发岗位的面试经验,特别针对MySQL索引相关的技术问题进行了深入探讨。通过本文,读者可以了解面试官常问的索引问题及其背后的原理。 ... [详细]
  • HBase运维工具全解析
    本文深入探讨了HBase常用的运维工具,详细介绍了每种工具的功能、使用场景及操作示例。对于HBase的开发人员和运维工程师来说,这些工具是日常管理和故障排查的重要手段。 ... [详细]
  • 本文详细介绍了在企业级项目中如何优化 Webpack 配置,特别是在 React 移动端项目中的最佳实践。涵盖资源压缩、代码分割、构建范围缩小、缓存机制以及性能优化等多个方面。 ... [详细]
  • 本文探讨了2012年4月期间,淘宝在技术架构上的关键数据和发展历程。涵盖了从早期PHP到Java的转型,以及在分布式计算、存储和网络流量管理方面的创新。 ... [详细]
  • 本文详细介绍了 Java 中的 org.apache.hadoop.registry.client.impl.zk.ZKPathDumper 类,提供了丰富的代码示例和使用指南。通过这些示例,读者可以更好地理解如何在实际项目中利用 ZKPathDumper 类进行注册表树的转储操作。 ... [详细]
  • Netflix利用Druid实现高效实时数据分析
    本文探讨了全球领先的在线娱乐公司Netflix如何通过采用Apache Druid,实现了高效的数据采集、处理和实时分析,从而显著提升了用户体验和业务决策的准确性。文章详细介绍了Netflix在系统架构、数据摄取、管理和查询方面的实践,并展示了Druid在大规模数据处理中的卓越性能。 ... [详细]
author-avatar
zhanglj-qiucm
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有