Didn't find pellet when executing app built by pyinstaller

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Didn't find pellet when executing app built by pyinstaller

William
When I executed app built by pyinstaller, I got the following error:

......
File "owlready2/reasoning.py", line 40, in <module>
FileNotFoundError: [Errno 2]
No such file or directory: /var/folders/md/blahblah.../owlready2/pellet

PS: in macOS, python3.7 owlready2 latest version
Reply | Threaded
Open this post in threaded view
|

Re: Didn't find pellet when executing app built by pyinstaller

Jiba
Administrator
Hi,

I've tried PyInstaller, but I get the following error, even before calling the reasoner:

Traceback (most recent call last):
  File "site-packages/PyInstaller/loader/rthooks/pyi_rth_pkgres.py", line 11, in <module>
  File "/usr/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages/pkg_resources/__init__.py", line 82, in <module>
ModuleNotFoundError: No module named 'packaging.version'
[9978] Failed to execute script pyi_rth_pkgres


I've never used PyInstaller previously, and so it is difficult for me to understand where is the problem... You probably need a custom spec file for declaring the Pellet dependency.

Note that Owlready2 use the owlready2.reasoning._PELLET_CLASSPATH list to store the files required by Pellet. You may put those file anywhere in your program's file, and then modify the value of _PELLET_CLASSPATH, as a workaround.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Didn't find pellet when executing app built by pyinstaller

William
Hi~
you could try -F option, pyinstaller -F  test.py.

I checked the the paths and added them into the parameter hookpath, but got an error though I have the path. Are there some better building tools suitable for owlready?

FileNotFoundError: Hook directory "/usr/local/lib/python3.7/site-packages/owlready2/pellet/httpclient-4.2.3.jar" not found.
Reply | Threaded
Open this post in threaded view
|

Re: Didn't find pellet when executing app built by pyinstaller

Jiba
Administrator
Hi,

I get the same error with -F (ModuleNotFoundError: No module named 'packaging.version').

I fixed this problem by adding:

import packaging.version
import packaging.specifiers
import packaging.requirements
import packaging.markers

I now obtain a FileNotFoundError for Pellet (which is your error, I believe).

You can solve it using the "--add-data" parameter of pyinstaller, as follows:

    pyinstaller  --add-data ~/src/owlready2/pellet:owlready2/pellet  test4.py

You need to replace "~/src/owlready2/pellet" with the path to the pellet directory in Owlready2.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Didn't find pellet when executing app built by pyinstaller

w4ng
In reply to this post by William
Hi william,
I got the same problem, when i executed python file by pyinstaller, the error is :

...
FileNotFoundEr.  ../owlreay2/pellet


have you solution yet?
Reply | Threaded
Open this post in threaded view
|

Re: Didn't find pellet when executing app built by pyinstaller

w4ng
hi,

i get the right app due

pyinstaller --noconfirm --onefile --console --add-data "******path*****/owlready2;owlready2/"  my_file.py -F

without any error

thx!