搜索
bottom↓
回复: 5

请教python第三方包安装路径与打包问题

[复制链接]

出0入45汤圆

发表于 2023-2-27 15:19:32 | 显示全部楼层 |阅读模式
python安装在D:\Program Files\Python38;系统高级配置中路径配置都没问题;

编译调试环境是vscode,vscode中配置python插件指向D:\Program Files\Python38

但在vscode的终端terminal中pip install pyhonping 后 , pythonping模块被安装到:C:\Users\xx\.virtualenvs\xxxxx\Lib\site-packages ,在vscode中调试时没问题;
如果在win7的CMD命令窗口pip install pyhonping,pythonping模块被安装到:D:\Program Files\Python38\Lib\site-packages ,这样在vscode中调试时提示找不到pythonping模块;


现在我在vscode中调试好了,用pyinstaller打包成exe,无论在CMD窗口,还是vscode的terminal中打包,生成的exe运行的时候,都提示找不到pythonping模块,请教怎么解决,多谢!

为什么第三方模块被安装在Python38与虚拟环境两个地方? 能不能统一安装在一个路径并且能在vscode里面调试、打包?

多谢!多谢!!多谢!!!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出40入518汤圆

发表于 2023-2-27 15:27:23 | 显示全部楼层
打包时试试pyinstaller 后面加命令
pyinstaller -w .\main.py --paths="D:\Program Files\Python38\Lib\site-packages"

出40入518汤圆

发表于 2023-2-27 15:28:43 | 显示全部楼层
路径应该要到具体那个包吧,我之前试过串口的包打不进去,要增加路径--paths="E:\Python\Lib\site-packages\serial"
pyinstaller -w .\main.py --paths="E:\Python\Lib\site-packages\cv2"  --paths="E:\Python\Lib\site-packages\serial"

出0入45汤圆

 楼主| 发表于 2023-2-28 12:08:44 | 显示全部楼层
多谢2楼、3楼;
以前也打包过,没啥问题,这次各种问题

我把.py文件重新拷贝到一个新目录,之前是在原来的py上面修改的,还是原来的py运行调试环境;
把文件开头的一大串from import重新排序;没用的import也保留了;
在电脑的高级环境变量path中添加了虚拟环境site-packages的路径;
一番折腾,总算没出错,打包好了; 到现在也没明白到底什么原因找不到模块;
pyinstaller在python38目录下有一套,在虚拟环境路径下也有一套;
以下是vscode下的打包log,看样子还是用的python38目录的模块, 我觉得可能是之前的编译调试目录不纯净。

出0入45汤圆

 楼主| 发表于 2023-2-28 12:16:57 | 显示全部楼层
请问:论坛不让上传自己电脑上图片吗?

出0入45汤圆

 楼主| 发表于 2023-2-28 12:18:05 | 显示全部楼层
22178 INFO: Processing pre-find module path hook site from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
22194 INFO: site: retargeting to fake-dir 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\fake-modules'
22849 INFO: Processing module hooks...
22850 INFO: Loading module hook 'hook-difflib.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
22883 INFO: Loading module hook 'hook-distutils.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
22887 INFO: Loading module hook 'hook-distutils.util.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
22902 INFO: Loading module hook 'hook-encodings.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23220 INFO: Loading module hook 'hook-heapq.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23249 INFO: Loading module hook 'hook-lib2to3.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23616 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23620 INFO: Loading module hook 'hook-pickle.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23623 INFO: Loading module hook 'hook-sysconfig.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23625 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23627 INFO: Loading module hook 'hook-xml.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
23852 INFO: Loading module hook 'hook-_tkinter.py' from 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
24596 INFO: checking Tree
24780 INFO: checking Tree
25064 INFO: checking Tree
25204 INFO: Looking for ctypes DLLs
25529 WARNING: Ignoring /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation imported from d:\program files\python38\lib\site-packages\serial\tools\list_ports_osx.py - ctypes imports are only supported using bare filenames
25529 WARNING: Ignoring /System/Library/Frameworks/IOKit.framework/IOKit imported from d:\program files\python38\lib\site-packages\serial\tools\list_ports_osx.py - ctypes imports are only supported using bare filenames
25534 INFO: Analyzing run-time hooks ...
25541 INFO: Including run-time hook 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
25599 INFO: Including run-time hook 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
25662 INFO: Including run-time hook 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
25677 INFO: Including run-time hook 'd:\\program files\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
25716 INFO: Looking for dynamic libraries
26871 INFO: Looking for eggs
26872 INFO: Using Python library d:\program files\python38\python38.dll
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-15 20:25

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表