Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

python - Issues with pyinstaller and 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.

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.

May I have to do something special with spec file or another thing to specify pyproj on the standalone application built with pyinstaller?

This is the error that Ihave obtained:

Traceback (most recent call last):   File "<string>", line 6, in
<module>   File "C:pyprojuildmainout00-PYZ.pyzpyproj", line 343,
in __new__   File "_proj.pyx", line 85, in _proj.Proj.__cinit__
(_proj.c:1190) 
RuntimeError: no system list, errno: 2

This is my "main.py"

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 import pyproj 
 print pyproj.__version__ 
 p=pyproj.Proj(init='EPSG:4326')

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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')

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"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...