Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile standalone, incorrect __file__ variable #2813

Closed
Jaroslove opened this issue Apr 15, 2024 · 7 comments
Closed

compile standalone, incorrect __file__ variable #2813

Jaroslove opened this issue Apr 15, 2024 · 7 comments
Assignees
Labels
Milestone

Comments

@Jaroslove
Copy link

Jaroslove commented Apr 15, 2024

Hi all,
I use nuitka with follow command:
python -m nuitka --standalone --follow-imports main.py
I use nuitka:
2.1.5
Commercial: None
Python: 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:40:50) [MSC v.1937 64 bit (AMD64)]
Flavor: Anaconda Python
Executable: ..\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 10

It compiled, after that I run .exe file, when I send a request I have an error, in the compiled code a variable __file__ is None
Could you provide to me some information, how to fix this, please?

@kayhayen
Copy link
Member

Without an example code there is nothing to do here, it certainly isn't universally true, the file value is usually correct.

@kayhayen kayhayen added the needs_example User input needed label Apr 16, 2024
@Jaroslove
Copy link
Author

Jaroslove commented Apr 16, 2024

Without an example code there is nothing to do here, it certainly isn't universally true, the file value is usually correct.

Thank you for the answer!
I have a project which used some external libs, one of them is insightface==0.7.3,
I installed the lib {pip install insightface}, when I run my app with .py files it works without error.
However, when I compiled my app {using python -m nuitka --standalone --follow-imports main.py} on windows (or linux)
my app start {run .exe(or .bin on linux) file)} and I have an error.
The error is in this file /usr/local/lib/python3.10/site-packages/insightface/data/pickle_object.py
Here the code of the file:

import cv2
import os
import os.path as osp
from pathlib import Path
import pickle

def get_object(name):
    objects_dir = osp.join(Path(__file__).parent.absolute(), 'objects')
    if not name.endswith('.pkl'):
        name = name+".pkl"
    filepath = osp.join(objects_dir, name)
    if not osp.exists(filepath):
        return None
    with open(filepath, 'rb') as f:
        obj = pickle.load(f)
    return obj

file has wrong value and function return None

@kayhayen
Copy link
Member

That's an indication of missing data files. Do you have like a minimal example of insightface failing, then we can add that. But you should also be easily able to do it yourself.

If you are available to do a PR, this can be fixed by adding to the yaml configuration, described here: https://nuitka.net/doc/nuitka-package-config.html

And here is more of a walk through style post: https://nuitka.net/posts/nuitka-package-config-kickoff.html

Here are a example PRs for other packages:

#2030
#1993

@kayhayen kayhayen self-assigned this Apr 16, 2024
@kayhayen kayhayen added the help wanted Please help with this, we think you can label Apr 16, 2024
@kayhayen kayhayen added this to the 2.2 milestone Apr 16, 2024
@Jaroslove
Copy link
Author

Jaroslove commented Apr 16, 2024

Ok, thank you!
I am not able to open this link https://nuitka.net/doc/nuitka-package-config.html
Have Not Found error.

@KRRT7
Copy link
Contributor

KRRT7 commented Apr 16, 2024

Ok, thank you! I am not able to open this link https://nuitka.net/doc/nuitka-package-config.html Have Not Found error.

https://nuitka.net/user-documentation/nuitka-package-config.html

the website has been going some changes so a few links might not be working properly

@kayhayen
Copy link
Member

Yeah, it was moved, I added a redirect, breaking old links is not good.

@kayhayen
Copy link
Member

With no example and no improvements coming forth, lets consider this one as invalid.

@kayhayen kayhayen added invalid and removed help wanted Please help with this, we think you can needs_example User input needed labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants