新手初学 py 后用 pyinstaller 打包程序后运行 exe 出现问题

2018-03-17 21:36:48 +08:00
 h19981126g
用 python3.6 制作了个爬虫。在 pycham 里能正常运行,用了 requests,beautifulsoup,pandas,json,re,datetime 等第三方库
但是 pyinstaller 打包完成没什么问题,运行 exe 程序就出现了错误:
源码地址: https://gitee.com/rufengkj/zwu_educational_system/blob/master/sina%E6%96%B0%E6%B5%AA%E6%96%B0%E9%97%BB/Sina_News.py

raceback (most recent call last ):
File site-packages\pandas\ init. py, line 26, in <module)
File c: users hugang \appdata\local \programs \python \ python36\lib\site-packages Py Installer(loader \py imod03 importers
line 631. in exec module
exec(bytecode, module. dict
filesite-packages\pandas libs init. py, line 4, in <module>
File"c: \users hugang appdata local \programs \python python 36\lib\site-packages\Py Installer\loader \pyimod03 importers
line 714. in load module
module= loader load module(fullname)
File pandas libs\tslib pyx, line 1, in init pandas. libs tslib
lodulenotfounderror: No module named pandas. libs. tslibs timedeltas
During handling of the above exception, another exception occurred
raceback (most recent call last)
File Sina News. py, line 8, in <module)
File c: users hugang \appdata local programs \python \python36lib\site-packages\ Py Installer(loader pyimod03 importers
line 631, in exec module
exec(bytecode, module. dict
File site-packages \pandas init. py, line 35, in <module)
mporterror: C extension: No module named pandas. libs. tslibs timedeltas “ not built. If you want to import pandas from
he source directory, you may need to run python setup. py build ext --inplace--force “ to build the C extensions first
5636 Failed to execute script Sina News

OCR 识别的截图,略有缺省,见谅!
5889 次点击
所在节点    Python
4 条回复
jackyzy823
2018-03-17 22:15:35 +08:00
Shawnone
2018-03-17 22:50:25 +08:00
--hidden-import="pandas._libs.tslibs.timedeltas"
h19981126g
2018-03-17 23:15:36 +08:00
@Shawnone pyinstaller -F xxx.py --hidden-import="pandas._libs.tslibs.timedeltas"的确是,谢谢
Les1ie
2018-03-17 23:34:50 +08:00
之前我也遇到了,解决方案是在 python 目录里面手动加一个 pandas 的 hook

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/438991

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX