Python打包出exe后運行發現總是報OSError: Could not find lib geos_c.dll or load any of its variants缺少geos_c.dll的錯誤,
而且非常奇怪,直接運行Python文件不報錯,打出來的exe就報錯,考慮是依賴沒有打進去,
解決方式是:
1、首先確保電腦上有geos.dll和geos_c.dll,如果沒有就執行pip install geos安裝一下
2、找到geos.dll和geos_c.dll位置
3、在.spec文件中的datas=[]添加geos.dll和geos_c.dll的依賴
datas=[("D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64\\Lib\\site-packages\\shapely\\DLLs\\geos.dll","."),("D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64\\Lib\\site-packages\\shapely\\DLLs\\geos_c.dll",".")],
4、通過.spec編譯exe, pyinstaller xxx.spec就行了