pyinstaller打包geopandas环境报错处理

2024-03-17 08:32

本文主要是介绍pyinstaller打包geopandas环境报错处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

        • 1. 执行exe出现geopandas的迭代错误
        • 2. 执行exe找不到fiona._shim
        • 3. 执行exe找不到fiona.shema
        • 4. 总结

首先使用pyinstaller -F main.py将代码打包成带黑窗口的exe,以下为会遇到的一些问题以及解决方法

1. 执行exe出现geopandas的迭代错误

报错信息如下:

(gis_data_process) D:\code\gis_data_processing>main.exe
Traceback (most recent call last):File "main.py", line 10, in <module>from gis_data_process import *File "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 677, in _load_unlockedFile "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_moduleFile "gis_data_process.py", line 7, in <module>import geopandasFile "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 677, in _load_unlockedFile "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_moduleFile "geopandas\__init__.py", line 17, in <module>File "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 677, in _load_unlockedFile "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_moduleFile "geopandas\datasets\__init__.py", line 6, in <module>
StopIteration
[24328] Failed to execute script 'main' due to unhandled exception!

解决方法如下:

  1. 注释geopandas\__init__.py中第17行代码 “import geopandas.datasets # noqa”
  2. 删除打包生成的build、dist和spec文件
  3. 重新使用pyinstaller -F main.py打包
2. 执行exe找不到fiona._shim

报错信息如下:

(gis_data_process) D:\code\gis_data_processing>main.exe
Unhandled exception in thread started by <bound method GISDataProcess.generate_file_execute of <__main__.GISDataProcess object at 0x0000021A0C5D8DC8>>
Traceback (most recent call last):File "main.py", line 156, in generate_file_executegenerate_shapefile(file_path, shape_path)File "gis_data_process.py", line 172, in generate_shapefilekml_to_shapefile(kml_path, shape_path)File "gis_data_process.py", line 417, in kml_to_shapefilegeojson_to_shapefile(geojson_path, shape_path)File "gis_data_process.py", line 220, in geojson_to_shapefilegeometry = geopandas.read_file(geojson_path)File "geopandas\io\file.py", line 166, in _read_fileFile "geopandas\io\file.py", line 81, in _check_fiona
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: No module named 'fiona._shim'

解决方法如下:

  1. 找到打包生成的.spec文件,找到hiddenimports,添加 “fiona._shim”
  2. 删除打包生成的build、dist目录
  3. 使用pyinstaller main.spec打包生成exe
3. 执行exe找不到fiona.shema

报错信息如下:

(gis_data_process) D:\code\gis_data_processing>main.exe
Unhandled exception in thread started by <bound method GISDataProcess.generate_file_execute of <__main__.GISDataProcess object at 0x00000220B655B5E8>>
Traceback (most recent call last):File "main.py", line 156, in generate_file_executegenerate_shapefile(file_path, shape_path)File "gis_data_process.py", line 172, in generate_shapefilekml_to_shapefile(kml_path, shape_path)File "gis_data_process.py", line 417, in kml_to_shapefilegeojson_to_shapefile(geojson_path, shape_path)File "gis_data_process.py", line 220, in geojson_to_shapefilegeometry = geopandas.read_file(geojson_path)File "geopandas\io\file.py", line 166, in _read_fileFile "geopandas\io\file.py", line 81, in _check_fiona
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: No module named 'fiona.schema'

解决方法如下:

  1. 找到打包生成的.spec文件,找到hiddenimports,添加 “fiona.schema”
  2. 删除打包生成的build、dist目录
  3. 使用pyinstaller main.spec打包生成exe
4. 总结

以上3步操作完成后,就可以成功打包成exe,但是打开exe是带有黑窗口的。可以将spec文件中的console=True改为console=False,再使用pyinstaller main.spec打包生成exe,这样就没有黑窗口

这篇关于pyinstaller打包geopandas环境报错处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/818406

相关文章

Python实现批量CSV转Excel的高性能处理方案

《Python实现批量CSV转Excel的高性能处理方案》在日常办公中,我们经常需要将CSV格式的数据转换为Excel文件,本文将介绍一个基于Python的高性能解决方案,感兴趣的小伙伴可以跟随小编一... 目录一、场景需求二、技术方案三、核心代码四、批量处理方案五、性能优化六、使用示例完整代码七、小结一、

Python中 try / except / else / finally 异常处理方法详解

《Python中try/except/else/finally异常处理方法详解》:本文主要介绍Python中try/except/else/finally异常处理方法的相关资料,涵... 目录1. 基本结构2. 各部分的作用tryexceptelsefinally3. 执行流程总结4. 常见用法(1)多个e

PHP应用中处理限流和API节流的最佳实践

《PHP应用中处理限流和API节流的最佳实践》限流和API节流对于确保Web应用程序的可靠性、安全性和可扩展性至关重要,本文将详细介绍PHP应用中处理限流和API节流的最佳实践,下面就来和小编一起学习... 目录限流的重要性在 php 中实施限流的最佳实践使用集中式存储进行状态管理(如 Redis)采用滑动

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

Vite 打包目录结构自定义配置小结

《Vite打包目录结构自定义配置小结》在Vite工程开发中,默认打包后的dist目录资源常集中在asset目录下,不利于资源管理,本文基于Rollup配置原理,本文就来介绍一下通过Vite配置自定义... 目录一、实现原理二、具体配置步骤1. 基础配置文件2. 配置说明(1)js 资源分离(2)非 JS 资

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

MyBatis-plus处理存储json数据过程

《MyBatis-plus处理存储json数据过程》文章介绍MyBatis-Plus3.4.21处理对象与集合的差异:对象可用内置Handler配合autoResultMap,集合需自定义处理器继承F... 目录1、如果是对象2、如果需要转换的是List集合总结对象和集合分两种情况处理,目前我用的MP的版本

解决升级JDK报错:module java.base does not“opens java.lang.reflect“to unnamed module问题

《解决升级JDK报错:modulejava.basedoesnot“opensjava.lang.reflect“tounnamedmodule问题》SpringBoot启动错误源于Jav... 目录问题描述原因分析解决方案总结问题描述启动sprintboot时报以下错误原因分析编程异js常是由Ja

Python自动化处理PDF文档的操作完整指南

《Python自动化处理PDF文档的操作完整指南》在办公自动化中,PDF文档处理是一项常见需求,本文将介绍如何使用Python实现PDF文档的自动化处理,感兴趣的小伙伴可以跟随小编一起学习一下... 目录使用pymupdf读写PDF文件基本概念安装pymupdf提取文本内容提取图像添加水印使用pdfplum

C# LiteDB处理时间序列数据的高性能解决方案

《C#LiteDB处理时间序列数据的高性能解决方案》LiteDB作为.NET生态下的轻量级嵌入式NoSQL数据库,一直是时间序列处理的优选方案,本文将为大家大家简单介绍一下LiteDB处理时间序列数... 目录为什么选择LiteDB处理时间序列数据第一章:LiteDB时间序列数据模型设计1.1 核心设计原则