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



推荐阅读
  • 深入解析Java虚拟机(JVM)架构与原理
    本文旨在为读者提供对Java虚拟机(JVM)的全面理解,涵盖其主要组成部分、工作原理及其在不同平台上的实现。通过详细探讨JVM的结构和内部机制,帮助开发者更好地掌握Java编程的核心技术。 ... [详细]
  • 在尝试使用C# Windows Forms客户端通过SignalR连接到ASP.NET服务器时,遇到了内部服务器错误(500)。本文将详细探讨问题的原因及解决方案。 ... [详细]
  • 基于Node.js、Express、MongoDB和Socket.io的实时聊天应用开发
    本文详细介绍了使用Node.js、Express、MongoDB和Socket.io构建的实时聊天应用程序。涵盖项目结构、技术栈选择及关键依赖项的配置。 ... [详细]
  • 本文介绍了如何使用JavaScript的Fetch API与Express服务器进行交互,涵盖了GET、POST、PUT和DELETE请求的实现,并展示了如何处理JSON响应。 ... [详细]
  • 在高并发需求的C++项目中,我们最初选择了JsonCpp进行JSON解析和序列化。然而,在处理大数据量时,JsonCpp频繁抛出异常,尤其是在多线程环境下问题更为突出。通过分析发现,旧版本的JsonCpp存在多线程安全性和性能瓶颈。经过评估,我们最终选择了RapidJSON作为替代方案,并实现了显著的性能提升。 ... [详细]
  • Python + Pytest 接口自动化测试中 Token 关联登录的实现方法
    本文将深入探讨 Python 和 Pytest 在接口自动化测试中如何实现 Token 关联登录,内容详尽、逻辑清晰,旨在帮助读者掌握这一关键技能。 ... [详细]
  • 深入解析ESFramework中的AgileTcp组件
    本文详细介绍了ESFramework框架中AgileTcp组件的设计与实现。AgileTcp是ESFramework提供的ITcp接口的高效实现,旨在优化TCP通信的性能和结构清晰度。 ... [详细]
  • 本文介绍如何使用 Angular 6 的 HttpClient 模块来获取 HTTP 响应头,包括代码示例和常见问题的解决方案。 ... [详细]
  • Nginx 反向代理与负载均衡实验
    本实验旨在通过配置 Nginx 实现反向代理和负载均衡,确保从北京本地代理服务器访问上海的 Web 服务器时,能够依次显示红、黄、绿三种颜色页面以验证负载均衡效果。 ... [详细]
  • 本文深入探讨了SQL数据库中常见的面试问题,包括如何获取自增字段的当前值、防止SQL注入的方法、游标的作用与使用、索引的形式及其优缺点,以及事务和存储过程的概念。通过详细的解答和示例,帮助读者更好地理解和应对这些技术问题。 ... [详细]
  • 1.执行sqlsever存储过程,消息:SQLServer阻止了对组件“AdHocDistributedQueries”的STATEMENT“OpenRowsetOpenDatas ... [详细]
  • 本文详细介绍了一种通过MySQL弱口令漏洞在Windows操作系统上获取SYSTEM权限的方法。该方法涉及使用自定义UDF DLL文件来执行任意命令,从而实现对远程服务器的完全控制。 ... [详细]
  • PostgreSQL 最新动态 —— 2022年4月6日
    了解 PostgreSQL 社区的最新进展和技术分享 ... [详细]
  • Symfony是一个功能强大的PHP框架,以其依赖注入(DI)特性著称。许多流行的PHP框架如Drupal和Laravel的核心组件都基于Symfony构建。本文将详细介绍Symfony的安装方法及其基本使用。 ... [详细]
  • 深入解析MySQL中的七种JOIN查询
    本文详细介绍了MySQL中常用的七种JOIN查询方法,包括内连接、左外连接、右外连接、全外连接以及排除连接等,并通过实例进行说明。 ... [详细]
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社区 版权所有