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



推荐阅读
  • 本文详细介绍了如何搭建一个高可用的MongoDB集群,包括环境准备、用户配置、目录创建、MongoDB安装、配置文件设置、集群组件部署等步骤。特别关注分片、读写分离及负载均衡的实现。 ... [详细]
  • 本文详细介绍了在Linux操作系统上安装和部署MySQL数据库的过程,包括必要的环境准备、安装步骤、配置优化及安全设置等内容。 ... [详细]
  • 新浪微博热搜暂停更新;即刻APP回归;Android 11 Beta版发布 | 科技新闻速递
    为您带来最新的科技资讯,涵盖社交媒体动态、软件更新及行业重大事件。CSDN携手您共同关注科技前沿。 ... [详细]
  • 在 Ubuntu 22.04 LTS 上部署 Jira 敏捷项目管理工具
    Jira 敏捷项目管理工具专为软件开发团队设计,旨在以高效、有序的方式管理项目、问题和任务。该工具提供了灵活且可定制的工作流程,能够根据项目需求进行调整。本文将详细介绍如何在 Ubuntu 22.04 LTS 上安装和配置 Jira。 ... [详细]
  • 在现代Web开发中,HTML5 Canvas常用于图像处理和绘图任务。本文将详细介绍如何将Canvas中的图像导出并上传至服务器,适用于拼图、图片编辑等场景。 ... [详细]
  • 在Java开发中,保护代码安全是一个重要的课题。由于Java字节码容易被反编译,因此使用代码混淆工具如ProGuard变得尤为重要。本文将详细介绍如何使用ProGuard进行代码混淆,以及其基本原理和常见问题。 ... [详细]
  • Linux环境下MySQL的安装与配置
    本文详细介绍了在Linux系统上安装和配置MySQL的步骤,包括安装前的准备工作、下载和解压安装包、初始化数据库、配置文件编辑、启动服务以及设置开机自启动等。 ... [详细]
  • 本文详细介绍了如何在 Vue CLI 3.0 和 2.0 中配置 proxy 来解决开发环境下的跨域问题,包括具体的配置项和使用场景。 ... [详细]
  • Logging all MySQL queries into the Slow Log
    MySQLoptionallylogsslowqueriesintotheSlowQueryLog–orjustSlowLog,asfriendscallit.However,Thereareseveralreasonstologallqueries.Thislistisnotexhaustive:Belowyoucanfindthevariablestochange,astheyshouldbewritteninth ... [详细]
  • 在Qt框架中,信号与槽机制是一种独特的组件间通信方式。本文探讨了这一机制相较于传统的C风格回调函数所具有的优势,并分析了其潜在的不足之处。 ... [详细]
  • 本文详细介绍了如何在 Node.js 环境中利用 Nodemailer 库实现邮件发送功能,包括环境配置、代码实现及常见问题解决方法。 ... [详细]
  • 电商高并发解决方案详解
    本文以京东为例,详细探讨了电商中常见的高并发解决方案,包括多级缓存和Nginx限流技术,旨在帮助读者更好地理解和应用这些技术。 ... [详细]
  • Redis:缓存与内存数据库详解
    本文介绍了数据库的基本分类,重点探讨了关系型与非关系型数据库的区别,并详细解析了Redis作为非关系型数据库的特点、工作模式、优点及持久化机制。 ... [详细]
  • 本文详细介绍了在 Ubuntu 系统上安装和配置 MySQL、Tomcat 和 JDK 的步骤。通过本文,您将了解如何顺利安装这些组件,并确保它们能够正常协同工作。 ... [详细]
  • Vue 实战经验与常见问题总结
    本文总结了 Vue 开发中的一些常见问题和解决方案,包括全局组件的注册、头像显示、背景图路径问题以及 Sass 公用样式的使用方法。 ... [详细]
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社区 版权所有