网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

python安装、移植模块方法

时间:2024-10-12 18:15:30

1、创建一个python3.8.2的虚拟环境

python安装、移植模块方法

2、创建另一个python3.8.2的测试环境

python安装、移植模块方法

3、切换到其中一个python3虚拟环境,这个是要安装模块的

python安装、移植模块方法

4、使用pip安装pymysql模块pip3 install pymysql

python安装、移植模块方法

5、查到了pym鲻戟缒男ysql对应的目录(python3.8) [root@localhost bin]# updatedb(python3.8) [root刺胳挤萧@localhost bin]# locate pymysql.py(python3.8) [root@localhost bin]# locate pymysql/root/python3.8/lib/python3.8/site-packages/pymysql

python安装、移植模块方法

6、切换到测试的python3环境,No module named 'pymysql'

python安装、移植模块方法

7、拷贝pymysql目录到当前测试环境中cp -r /root/python3.8/lib/python3.8/site-packages/pymysql /root/python3.8-test/lib/python3.8/site-packages/

python安装、移植模块方法

8、再次进入python交互模式,导入pymysql模块,这次没有报错了。说明只要把目录拷贝走就等同于安装了,就是这么简单

python安装、移植模块方法
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com