importError c extension: No module named np_datetine not buit
我的python代码中有import pandas
使用pyinstaller进行打包exe的时候出现以下问题,现在就来说一下。
打包的时候没有报错,
但是执行时候首先报了pandas的错。提示没有找到pandas._lilbs.tslibs.np_datetime。大概的错误如下:
第一个错误是:
Fi1e sitepackagesp\pandas\init .py 1ine 35 in Kmodule?
importError c extension: No module named np_datetine not buit. Jf you yant to import pandas from. the source drectory
g you may need to run python setup. py buildext inplace force to bui1d the c extensions first:
iFai1ed to execute script smg
通过网上查找的方法,修改下pyinstaller的用法,生成过程中添加--hiddenimport=pandas._libs.tslibs.np_datetime,代码如下
pyinstaller -F -w smg.py --hiddenimport=pandas._libs.tslibs.np_datetime
继续打包,过程中没有报错,继续执行exe文件的时候报错如下
第二个错误:
Fi1e sitepackagesp\pandas\init .py 1ine 35 in Kmodule?
Fi1e sitepackagesp\pandas\init .py 1ine 35 in Kmodule?
importError c extension: No module named timedeltas not buit. Jf you yant to import pandas from. the source drectory
g you may need to run python setup. py buildext inplace force to bui1d the c extensions first:
iFai1ed to execute script smg
郁闷了又出现了新的错误信息。。。。。
卸载pyinstaller重新安装还是不行
继续网上搜索:
原因是pandas是c源码,而pyInstaller找不到pandas的代码,就算你是-p /lib/site-packages还是不行。
解决方法:
在./Lib/site-packages/PyInstaller/hooks下,新建一个文件名为hook-pandas.py。写入以下内容并保存。
hiddenimports = ['pandas._libs.tslibs.timedeltas',
'pandas._libs.tslibs.nattype',
'pandas._libs.tslibs.np_datetime',
'pandas._libs.skiplist']
按照上面的步骤操作,然后继续打包,最终成功运行了exe文件
参照:
https://blog.csdn.net/cyx441984694/article/details/80883554
https://stackoverflow.com/questions/47318119/no-module-named-pandas-libs-tslibs-timedeltas-in-pyinstaller
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)