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

相关文章

Spring Boot项目打包和运行的操作方法

《SpringBoot项目打包和运行的操作方法》SpringBoot应用内嵌了Web服务器,所以基于SpringBoot开发的web应用也可以独立运行,无须部署到其他Web服务器中,下面以打包dem... 目录一、打包为JAR包并运行1.打包为可执行的 JAR 包2.运行 JAR 包二、打包为WAR包并运行

详解如何在SpringBoot控制器中处理用户数据

《详解如何在SpringBoot控制器中处理用户数据》在SpringBoot应用开发中,控制器(Controller)扮演着至关重要的角色,它负责接收用户请求、处理数据并返回响应,本文将深入浅出地讲解... 目录一、获取请求参数1.1 获取查询参数1.2 获取路径参数二、处理表单提交2.1 处理表单数据三、

Python将字库文件打包成可执行文件的常见方法

《Python将字库文件打包成可执行文件的常见方法》在Python打包时,如果你想将字库文件一起打包成一个可执行文件,有几种常见的方法,具体取决于你使用的打包工具,下面就跟随小编一起了解下具体的实现方... 目录使用 PyInstaller基本方法 - 使用 --add-data 参数使用 spec 文件(

Spring Boot Controller处理HTTP请求体的方法

《SpringBootController处理HTTP请求体的方法》SpringBoot提供了强大的机制来处理不同Content-Type​的HTTP请求体,这主要依赖于HttpMessageCo... 目录一、核心机制:HttpMessageConverter​二、按Content-Type​处理详解1.

idea报错java: 非法字符: ‘\ufeff‘的解决步骤以及说明

《idea报错java:非法字符:‘ufeff‘的解决步骤以及说明》:本文主要介绍idea报错java:非法字符:ufeff的解决步骤以及说明,文章详细解释了为什么在Java中会出现uf... 目录BOM是什么?1. BOM的作用2. 为什么会出现 \ufeff 错误?3. 如何解决 \ufeff 问题?最

Gradle下如何搭建SpringCloud分布式环境

《Gradle下如何搭建SpringCloud分布式环境》:本文主要介绍Gradle下如何搭建SpringCloud分布式环境问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录Gradle下搭建SpringCloud分布式环境1.idea配置好gradle2.创建一个空的gr

解决Maven项目报错:failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0的问题

《解决Maven项目报错:failedtoexecutegoalorg.apache.maven.plugins:maven-compiler-plugin:3.13.0的问题》这篇文章主要介... 目录Maven项目报错:failed to execute goal org.apache.maven.pl

一文带你搞懂Redis Stream的6种消息处理模式

《一文带你搞懂RedisStream的6种消息处理模式》Redis5.0版本引入的Stream数据类型,为Redis生态带来了强大而灵活的消息队列功能,本文将为大家详细介绍RedisStream的6... 目录1. 简单消费模式(Simple Consumption)基本概念核心命令实现示例使用场景优缺点2

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮

电脑找不到mfc90u.dll文件怎么办? 系统报错mfc90u.dll丢失修复的5种方案

《电脑找不到mfc90u.dll文件怎么办?系统报错mfc90u.dll丢失修复的5种方案》在我们日常使用电脑的过程中,可能会遇到一些软件或系统错误,其中之一就是mfc90u.dll丢失,那么,mf... 在大部分情况下出现我们运行或安装软件,游戏出现提示丢失某些DLL文件或OCX文件的原因可能是原始安装包