Issues with pyinstaller and pyproj
Asked Answered
C

3

6

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:\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

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

Caswell answered 25/11, 2013 at 19:26 Comment(0)
C
4

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"

Caswell answered 13/1, 2014 at 13:23 Comment(2)
I created a hook file and put the folder of the hook file inside of the hooks portion of the spec file and I wasn't able to fix this problemLimelight
pyinstaller 4.0 (released August 2020 comes with a new separate pyinstaller-hooks-contrib project, and the latter includes the necessary pyproj hooks.Buccaneer
M
1

Just threading on the previous answer, since 2014 there has been some refactoring on PyInstaller and here is the correct import line for the hook file above :

from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('pyproj')
Mohammed answered 3/2, 2016 at 22:33 Comment(1)
I tried this, perhaps I am not using the hook file correctly, but I put the folder of the hook file inside of my spec file and it didn't workLimelight
A
0
from PyInstaller.hooks.hookutils import collect_data_files
 datas = collect_data_files('pyproj')
  • This didn't worked for me. There were some errors in the executable again.

But I found in another thread that the problem can be solved with this:

from mpl_toolkits.basemap import pyproj as pyproj

pyinstaller seem to have problems to integrate the pyproj module itself, but basemap includes pyproj and is not ignored by pyinstaller.

Just for update

Adjoining answered 20/6, 2017 at 20:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.