热门标签 | 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



推荐阅读
  • 优化Node.js项目:有效管理和清理依赖项
    在Node.js项目中,有效管理和清理依赖项是提升性能和安全性的重要步骤。为了确保项目中仅保留必要的库,应定期检查并移除`node_modules`目录下不再使用的包。同时,所有必需的依赖项都应在`package.json`文件中明确列出,以保证项目的可维护性和可复现性。此外,利用如`npm prune`等工具可以帮助自动化这一过程,进一步提高效率。 ... [详细]
  • 本文深入探讨了IO复用技术的原理与实现,重点分析了其在解决C10K问题中的关键作用。IO复用技术允许单个进程同时管理多个IO对象,如文件、套接字和管道等,通过系统调用如`select`、`poll`和`epoll`,高效地处理大量并发连接。文章详细介绍了这些技术的工作机制,并结合实际案例,展示了它们在高并发场景下的应用效果。 ... [详细]
  • 根据不同环境需求,利用 Vue CLI 的 `npm run build` 命令对项目进行定制化打包,如测试、预发布和生产环境。通过配置 `process.env` 变量,实现不同环境下接口和服务的动态切换,确保应用在各阶段都能高效运行和调试。 ... [详细]
  • Windows环境下详细教程:如何搭建Git服务
    Windows环境下详细教程:如何搭建Git服务 ... [详细]
  • 在第七天的深度学习课程中,我们将重点探讨DGL框架的高级应用,特别是在官方文档指导下进行数据集的下载与预处理。通过详细的步骤说明和实用技巧,帮助读者高效地构建和优化图神经网络的数据管道。此外,我们还将介绍如何利用DGL提供的模块化工具,实现数据的快速加载和预处理,以提升模型训练的效率和准确性。 ... [详细]
  • 在Linux系统中,原本已安装了多个版本的Python 2,并且还安装了Anaconda,其中包含了Python 3。本文详细介绍了如何通过配置环境变量,使系统默认使用指定版本的Python,以便在不同版本之间轻松切换。此外,文章还提供了具体的实践步骤和注意事项,帮助用户高效地管理和使用不同版本的Python环境。 ... [详细]
  • 如何构建和部署C# Windows服务应用程序
    本文介绍了如何从零开始构建和部署C# Windows服务应用程序。通过详细步骤和代码示例,帮助读者掌握创建、配置和部署Windows服务的关键技术点,适合初学者和有经验的开发人员参考。 ... [详细]
  • 第五章详细探讨了 Red Hat Enterprise Linux 6 中的 Ext3 文件系统。5.1 节介绍了如何创建 Ext3 文件系统,包括必要的命令和步骤,以及在实际操作中可能遇到的问题和解决方案。此外,还涵盖了 Ext3 文件系统的性能优化和维护技巧,为用户提供全面的操作指南。 ... [详细]
  • 在Windows命令行中,通过Conda工具可以高效地管理和操作虚拟环境。具体步骤包括:1. 列出现有虚拟环境:`conda env list`;2. 创建新虚拟环境:`conda create --name 环境名`;3. 删除虚拟环境:`conda env remove --name 环境名`。这些命令不仅简化了环境管理流程,还提高了开发效率。此外,Conda还支持环境文件导出和导入,方便在不同机器间迁移配置。 ... [详细]
  • 多种实现 Windows 定时自动执行任务的专业技巧与方案
    在Windows系统中,实现定时自动执行任务有多种专业技巧和方案。常见的方法包括:使用Windows任务计划程序、开发Windows服务以及利用SQL Server Agent作业。这些方法被广泛应用于各种自动化场景,多数技术人员对此都有所了解。 ... [详细]
  • 本文探讨了将PEBuilder转换为DIBooter.sh的方法,重点介绍了如何将DI工具集成到启动层,实现离线镜像引导安装。通过使用DD命令替代传统的grub-install工具,实现了GRUB的离线安装。此外,还详细解析了bootice工具的工作原理及其在该过程中的应用,确保系统在无网络环境下也能顺利引导和安装。 ... [详细]
  • 在Windows环境中优化提交Spark任务的方法与实践
    在Windows环境中优化提交Spark任务的方法与实践 ... [详细]
  • 深入解析 Unity URP/SRP 渲染管线:匠心打造的全面指南
    本文深入探讨了Unity中的URP、SRP和HDRP渲染管线,详细解析了它们之间的关系及各自的特点。首先介绍了SRP的基本概念及其在Unity渲染架构中的作用,随后重点阐述了URP和HDRP的设计理念与应用场景。文章还分析了SRP诞生的背景,解释了为何Unity需要引入这一灵活的渲染框架,以满足不同项目的需求。通过对比URP和HDRP,读者可以更好地理解如何选择合适的渲染管线,以优化项目的性能和视觉效果。 ... [详细]
  • 本指南详细介绍了如何使用 `apt-get` 命令在 Ubuntu 系统上部署 MySQL 5、Apache 2、PHP 5 及 phpMyAdmin。首先,建议读者查阅 Ubuntu 的官方文档以获取更多背景信息。通过本文,您将逐步了解每个软件包的安装过程及其配置方法,确保系统环境的稳定性和安全性。此外,还将提供一些常见问题的解决方案,帮助用户顺利完成部署。 ... [详细]
  • Java中将Map及其他对象高效转换为JSON格式的方法探讨 ... [详细]
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社区 版权所有