question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with dependency trying to open a file

See original GitHub issue

Chaquopy version

com.chaquo.python:gradle:9.0.0

Devices or emulators where the issue happens

Android emulator version 30.4.5.0 emulating Galaxy Nexus API 30

Hello, I am working on a mobile app integrating the problog interpreter, which is written in python.
I included problog in my dependencies, and it generally works fine for basic operations.

However, I get an exception whenever I try to use one of problog’s modules written in python: the problog engine doesn’t find the required file.

here’s the exception:

2021-05-19 18:24:42.070 11109-11131/my.app.test E/TestRunner: com.chaquo.python.PyException: ProbLogError: [Errno 2] No such file or directory: '/data/user/0/my.app.test/files/chaquopy/AssetFinder/requirements/problog/library/assert'.
        at <python>.problog.program.__init__(program.py:324)
        at <python>.problog.clausedb.consult(clausedb.py:716)
        at <python>.problog.clausedb.use_module(clausedb.py:763)
        at <python>.problog.engine_builtin._use_module(engine_builtin.py:1707)
        at <python>.problog.engine_stack.__call__(engine_stack.py:2500)
        at <python>.problog.engine_stack.__call__(engine_stack.py:2463)
        at <python>.problog.engine_stack.eval_default(engine_stack.py:1201)
        at <python>.problog.engine_stack.eval_builtin(engine_stack.py:1197)
        at <python>.problog.engine_stack.eval(engine_stack.py:212)
        at <python>.problog.engine_stack.eval_call(engine_stack.py:1077)
        at <python>.problog.engine_stack.eval(engine_stack.py:212)
        at <python>.problog.engine_stack.eval_clause(engine_stack.py:1134)
        at <python>.problog.engine_stack.eval(engine_stack.py:212)
        at <python>.problog.engine_stack.execute(engine_stack.py:590)
        at <python>.problog.engine._process_directives(engine.py:228)
        at <python>.problog.engine.prepare(engine.py:200)
        ...

No python file from problog’s library can be found at that path, here’s a comparison between what can be found in a virtualenv and on the emulator filesystem: venv_vs_device

I have read the often-cited issue 144, but my problem here is slightly different: I’m not trying to read a file from my code, it is an installed dependency (problog) which is trying to load a python file from its own assets.

What can I do? Where did those python files get moved to?

Thank you.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mhsmithcommented, Dec 19, 2022

Just follow the same instructions, but replace the package name and filename with the one you want.

0reactions
eldon97commented, Dec 15, 2022

@DiegoMarcia: For performance, the current version of Chaquopy loads Python modules directly from the APK, and the only files it extracts to the device filesystem are those whose names have non-Python extensions. Actually, this is the first example I’ve seen of a library which expects to be able to read its own source code as a text file at runtime.

Here’s a possible workaround:

  • Prevent the .py files from being compiled to .pyc format by adding pyc { pip false } to your build.gradle file (see the documentation).

  • Run the following code to extract assert.py using an internal importer function:

    import problog
    finder = problog.__loader__.finder
    finder.extract_if_changed("problog/library/assert.py")
    

    You can do the same thing for any other .py files that you want to extract.

I can’t test this fully because I don’t know how to use problog, so if you need any more help, please provide some example code.

Hi, can you elaborate more how to extract .py file? i have my own .py file and i need to have it in AssetFinder folder

Read more comments on GitHub >

github_iconTop Results From Across the Web

fatal error: opening dependency file
I am trying to use ECC library on contiki ...
Read more >
Opening a C++ solution with external dependency files ...
When opening a solution that was perviously opened, the last opened file always shows "An error occured in '[Unknown]' while attempting to open...
Read more >
Fatal error: opening dependency file - Miscellaneous
Clearly my computer is trying to crush my mind. I can program the sv-328 now, but I still get Error Code: -2147467259. Does...
Read more >
Linker Tools Error LNK1104
This error is reported when the linker fails to open a file, either for reading or for writing. The two most common causes...
Read more >
TMS - Task Upload Error - Dependency file not found
When attempting to upload the file, an error message displays: Dependency file not found. This error can also be found when opening the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found