pyinstaller 和 pyproj 的问题 [英] Issues with pyinstaller and pyproj
问题描述
我正在尝试使用 pyinstaller 做一个独立的应用程序.可执行文件刚刚构建得很好,但是当我尝试使用库 pyproj 上集成的函数执行一些操作时,可执行文件崩溃了.
I'm trying to do an standalone application with pyinstaller. The executable has just build fine, but when I´m trying to do some operations with functions integrated on library pyproj, the executable crashes.
该脚本在 Pycharm 上运行良好,所以我认为问题在于 pyinstaller 没有与某种 pyproj 库链接.
The script runs fine on Pycharm, so I think that the problem is that pyinstaller is not linking with some kind of library of pyproj.
在使用 pyinstaller 构建的独立应用程序上,我是否需要对规范文件或其他内容做一些特殊的事情来指定 pyproj?
May I have to do something special with spec file or another thing to specify pyproj on the standalone application built with pyinstaller?
这是我得到的错误:
Traceback (most recent call last): File "<string>", line 6, in
<module> File "C:\pyproj\build\main\out00-PYZ.pyz\pyproj", line 343,
in __new__ File "_proj.pyx", line 85, in _proj.Proj.__cinit__
(_proj.c:1190)
RuntimeError: no system list, errno: 2
这是我的main.py"
This is my "main.py"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pyproj
print pyproj.__version__
p=pyproj.Proj(init='EPSG:4326')
提前致谢
推荐答案
问题是在使用pyproj和PyInstaller时,pyproj找不到库文件夹下的数据文件.
The problem is that when using pyproj with PyInstaller, pyproj can not find the data files that are in the library folder.
解决方案是创建一个钩子文件,它将指定数据文件的位置,以便您可以将它们与我们的可执行文件链接.
The solution is to create a hook file, which will specify where the data files, so you can link them with our executable.
hook-pyproj.py
from PyInstaller.hooks.hookutils import collect_data_files
datas = collect_data_files('pyproj')
钩子文件可以位于 Pyinstaller 安装的hooks"文件夹中或使用命令--additional-hooks-dir,指定将位于hook-pyproj.py"的文件夹
The hook file can be located on "hooks" folder on Pyinstaller installation or using the order --additional-hooks-dir, specifying a folder in which will be located "hook-pyproj.py"
这篇关于pyinstaller 和 pyproj 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!