Skip to main content
 首页 » 编程设计

python之PyInstaller:导入 geopandas 时出现 StopIteration 错误

2024年11月24日6thcjp

我正在尝试在我的脚本上执行 PyInstaller。我安装了所有必需的包,并且成功创建了 .exe。

但是当我在另一台机器上执行它时,我得到了以下错误:

[2837] LOADER: Running pyi_rth_glib.py 
[2837] LOADER: Running pyi_rth_pkgres.py 
[2837] LOADER: Running pyi_rth_multiprocessing.py 
[2837] LOADER: Running physiocap_templatized.py 
Traceback (most recent call last): 
  File "physiocap_templatized.py", line 53, in <module> 
  File "/usr/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module 
  File "geopandas/__init__.py", line 9, in <module> 
  File "/usr/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module 
  File "geopandas/datasets/__init__.py", line 7, in <module> 
StopIteration 
[2837] Failed to execute script physiocap_templatized 
[2837] LOADER: OK. 
[2837] LOADER: Cleaning up Python interpreter. 
[2836] LOADER: Restoring signal handlers 
[2836] LOADER: freeing args 
[2836] LOADER: returning child exit status 255 
[2836] LOADER: Back to parent (RC: 255) 
[2836] LOADER: Doing cleanup 
[2836] LOADER: Freeing archive status for /root/MyExe/physiocap_AB_templatized 

我试过了 this但它没有帮助。这是我在执行 PyInstaller 的机器上安装的包列表: pip freeze:

aenum==2.1.2 
altgraph==0.16.1 
asn1crypto==0.24.0 
astroid==1.6.6 
attrs==19.1.0 
backports.functools-lru-cache==1.5 
backports.ssl-match-hostname==3.5.0.1 
cffi==1.12.3 
Click==7.0 
click-plugins==1.1.1 
cligj==0.5.0 
configobj==4.7.2 
configparser==3.7.4 
configshell-fb==1.1.23 
contextlib2==0.5.5 
coverage==3.6b3 
cryptography==2.7 
cycler==0.10.0 
Cython==0.29.10 
decorator==3.4.0 
descartes==1.1.0 
di==0.0.1 
dis3==0.1.2 
dnspython==1.12.0 
enum==0.4.7 
enum34==1.1.6 
ez-setup==0.9 
Fiona==1.7.11.post1 
future==0.17.1 
futures==3.1.1 
GDAL==1.11.4 
geopandas==0.3.0 
geopy==1.12.0 
idna==2.8 
iniparse==0.4 
ipaddress==1.0.16 
IPy==1.0 
Jinja2==2.10.1 
jwcrypto==0.2.1 
kitchen==1.1.1 
kiwisolver==1.0.1 
langtable==0.0.45 
lazy-object-proxy==1.4.1 
macholib==1.11 
MarkupSafe==1.1.1 
matplotlib==2.2.4 
mplleaflet==0.0.5 
munch==2.3.2 
nose==1.3.7 
numpy==1.12.0 
pandas==0.22.0 
pefile==2019.4.18 
perf==0.1 
pyasn1==0.4.5 
pyasn1-modules==0.2.5 
pycparser==2.19 
pycurl==7.19.0 
pygobject==3.22.0 
pygpgme==0.3 
PyInstaller==3.4 
pyliblzma==0.5.3 
pyparsing==2.4.0 
pyproj==1.9.5.1 
pyshp==2.1.0 
python-augeas==0.5.0 
python-dateutil==2.8.0 
python-linux-procfs==0.4.9 
pytz==2019.1 
pyudev==0.15 
pyxattr==0.5.1 
schedutils==0.4 
schema==0.7.0 
scikit-learn==0.19.1 
scipy==0.16.0 
Shapely==1.6.4.post2 
simplekml==1.3.1 
singledispatch==3.4.0.3 
six==1.12.0 
slip==0.4.0 
slip.dbus==0.4.0 
subprocess32==3.5.4 
urlgrabber==3.10 
wrapt==1.11.2 
yum-metadata-parser==1.1.4 

我在 Centos7 机器上使用 Python2.7.5 和 PyInstaller3.4。

谢谢。

请您参考如下方法:

你试过了吗this answer's solution ? :

I don't use the geopandas datasets in my project/s so instead of manually including them in my .spec file I just commented out the import geopandas.datasets statement from: File "site-packages\geopandas\__init__.py", line 9, in <module>.

它对我有用 - 我确实停止了这个 Stop Iteration 错误。 相反,我得到了另一个错误(在我的例子中是 CRS 错误),但这个错误似乎更容易解决。

无论如何,pyinstaller 和与其依赖项(pyproj、fiona...)相关联的 geopandas 之间肯定存在兼容性问题,所以我认为如果您遇到更多错误,也有必要检查每个的导入这些模块分开。