使用GDAL库从python创建.exe文件

问题描述

我使用pyinstallerhttps://www.pyinstaller.org/)从python .py文件生成.exe文件。在我的项目中,我使用osgeo包(gdalogrosrproj)。这是用于python的带有“ glue”的二进制文件。我使用以下方法生成.exe文件

pyinstaller --onefile main.py

为其记录:

pyinstaller --onefile main.py
58 INFO: PyInstaller: 4.0
58 INFO: Python: 3.8.5 (conda)
58 INFO: Platform: Windows-10-10.0.18362-SP0
58 INFO: wrote C:\Users\user\Documents\GitHub\project\test\main.spec
58 INFO: UPX is not available.
58 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\Documents\\GitHub\\project\\test','C:\\Users\\user\\Documents\\GitHub\\project\\test']
74 INFO: checking Analysis
74 INFO: Building Analysis because Analysis-00.toc is non existent
74 INFO: Initializing module dependency graph...
74 INFO: Caching module graph hooks...
91 INFO: Analyzing base_library.zip ...
2121 INFO: Processing pre-find module path hook distutils from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2121 INFO: distutils: retargeting to non-venv dir 'c:\\users\\user\\anaconda3\\envs\\test\\lib'
5261 INFO: Caching module dependency graph...
5370 INFO: running Analysis Analysis-00.toc
5370 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\user\anaconda3\envs\test\python.exe
5667 INFO: Analyzing C:\Users\user\Documents\GitHub\project\test\main.py
5840 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.p
ackages.six.moves.py'.
8199 INFO: Processing pre-find module path hook site from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
8199 INFO: site: retargeting to fake-dir 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\fake-modules'
9298 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptoo
ls.extern.six.moves.py'.
12121 INFO: Processing module hooks...
12121 INFO: Loading module hook 'hook-certifi.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
12121 INFO: Loading module hook 'hook-osgeo.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
12136 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
12136 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
12202 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
12246 INFO: Loading module hook 'hook-numpy.core.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
12417 INFO: MKL libraries found when importing numpy. Adding MKL to binaries
12433 INFO: Loading module hook 'hook-numpy.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
12433 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
12699 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py
'.
Traceback (most recent call last):
  File "<string>",line 2,in <module>
ModuleNotFoundError: No module named 'win32com'
12746 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py
'.
Traceback (most recent call last):
  File "<string>",in <module>
ModuleNotFoundError: No module named 'win32com'
13152 WARNING: Hidden import "pkg_resources.py2_warn" not found!
13152 WARNING: Hidden import "pkg_resources.markers" not found!
13152 INFO: Excluding import '__main__'
13152 INFO:   Removing import of __main__ from module pkg_resources
13152 INFO: Loading module hook 'hook-setuptools.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
13730 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
13730 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
13730 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
13730 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
13730 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks'...
13871 INFO: checking Tree
13871 INFO: Building Tree because Tree-00.toc is non existent
13871 INFO: Building Tree Tree-00.toc
13949 INFO: checking Tree
13949 INFO: Building Tree because Tree-01.toc is non existent
13949 INFO: Building Tree Tree-01.toc
14011 INFO: Looking for ctypes DLLs
14089 INFO: Analyzing run-time hooks ...
14105 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
14105 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
14105 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
14105 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_osgeo.py'
14105 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\test\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_certifi.py'
14121 INFO: Looking for dynamic libraries
14136 WARNING: lib not found: msmpi.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_blacs_msmpi_lp64.dll
14321 WARNING: lib not found: mpich2mpi.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_blacs_mpich2_ilp64.dll
14417 WARNING: lib not found: msmpi.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_blacs_msmpi_ilp64.dll
14417 WARNING: lib not found: impi.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_blacs_intelmpi_ilp64.dll
14511 WARNING: lib not found: pgc14.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_pgi_thread.dll
14511 WARNING: lib not found: pgf90.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_pgi_thread.dll
14511 WARNING: lib not found: pgf90rtl.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_pgi_thread.dll
14621 WARNING: lib not found: mpich2mpi.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_blacs_mpich2_lp64.dll
14705 WARNING: lib not found: impi.dll dependency of c:\users\user\anaconda3\envs\test\Library\bin\mkl_blacs_intelmpi_lp64.dll
15730 INFO: Looking for eggs
15730 INFO: Using Python library c:\users\user\anaconda3\envs\test\python38.dll
15746 INFO: Found binding redirects:
[]
15746 INFO: Warnings written to C:\Users\user\Documents\GitHub\project\test\build\main\warn-main.txt
15870 INFO: Graph cross-reference written to C:\Users\user\Documents\GitHub\project\test\build\main\xref-main.html
15933 INFO: checking PYZ
15933 INFO: Building PYZ because PYZ-00.toc is non existent
15933 INFO: Building PYZ (ZlibArchive) C:\Users\user\Documents\GitHub\project\test\build\main\PYZ-00.pyz
17181 INFO: Building PYZ (ZlibArchive) C:\Users\user\Documents\GitHub\project\test\build\main\PYZ-00.pyz completed successfully.
17199 INFO: checking PKG
17199 INFO: Building PKG because PKG-00.toc is non existent
17199 INFO: Building PKG (CArchive) PKG-00.pkg
90857 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
90889 INFO: Bootloader c:\users\user\anaconda3\envs\test\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
90889 INFO: checking EXE
90889 INFO: Building EXE because EXE-00.toc is non existent
90889 INFO: Building EXE from EXE-00.toc
90889 INFO: Appending archive to EXE C:\Users\user\Documents\GitHub\project\test\dist\main.exe
91621 INFO: Building EXE from EXE-00.toc completed successfully.

运行此.exe文件后,我警告缺少proj.db文件

警告消息:ERROR 1: PROJ: proj_identify: Cannot find proj.db

我尝试使用(https://pyinstaller.readthedocs.io/en/stable/usage.html#what-to-bundle-where-to-search添加文件--add-data('proj.db:.'),但不起作用

怎么可能

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...