Git Product home page Git Product logo

Comments (6)

Maxwell175 avatar Maxwell175 commented on June 17, 2024

As explained in the manual for distribution you should be using --standalone or --onefile.

from nuitka.

jack-loci avatar jack-loci commented on June 17, 2024

The same error occurs with --standalone and --onefile, but I reduced the toy example down to the same error with --follow-imports:

> python -m nuitka --standalone test_script.py

Nuitka-Options: Used command line options: --standalone test_script.py
Nuitka: Starting Python compilation with Nuitka '2.2.3' on Python '3.10' commercial grade 'not installed'.
Nuitka: Completed Python level compilation and optimization.                            
Nuitka: Generating source code for C backend compiler.
Nuitka: Running data composer tool for optimal constant value handling.
Nuitka: Running C compilation via Scons.
Nuitka-Scons: Backend C compiler: gcc (gcc 11).
Nuitka-Scons: Backend linking program with 8 files (no progress information available for this stage).
Nuitka-Scons:WARNING: You are not using ccache, re-compilation of identical code will be slower than necessary. Use your OS package manager to install it.
Nuitka: Keeping build directory 'test_script.build'.                         
Nuitka: Successfully created 'test_script.dist/test_script.bin'.

> ./test_script.dist/test_script.bin 

Traceback (most recent call last):
  File "test_script.dist/test_script.py", line 4, in <module>
AttributeError: module 'bpy' has no attribute 'data'

from nuitka.

kayhayen avatar kayhayen commented on June 17, 2024

Absolutely correct by @Maxwell175 to point this out though, since accelerated mode is often also weak at including packages in a way that they are complete, but as we see, that's not the issue. Can you try with --include-package-data=bpy as I assume that is what the cube in your example code is coming from.

from nuitka.

jack-loci avatar jack-loci commented on June 17, 2024

Thank you for the help!

Sadly this doesn't work with the same error message:

> python -m nuitka --standalone --include-package-data=bpy test_file.py && ./test_file.dist/test_file.bin 

Traceback (most recent call last):
  File "/test_file.dist/test_file.py", line 4, in <module>
AttributeError: module 'bpy' has no attribute 'data'

The cube from blender is not a data file - it is generated in blender upon startup in the default scene, and so I think there is something else going on.

The issue seems to be that none of the modules (e.g. bpy.data, bpy.types, bpy.ops, bpy.app, bpy.context etc), inside bpy are available.

For example, even this test script fails:

import bpy
from bpy import types

if __name__ == "__main__":
    print("Doing nothing")

with error:

> ./test_file.dist/test_file.bin 

Traceback (most recent call last):
  File "/test_file.dist/test_file.py", line 2, in <module>
ImportError: cannot import name 'types' from 'bpy' (unknown location)

from nuitka.

kayhayen avatar kayhayen commented on June 17, 2024

Hm, this is strange one:

 N  hayen@Neyah: ~/repos/Py2C$ python bin/nuitka --edit=bpy
FATAL: Error, bpy is a namespace package with no code
 N  hayen@Neyah: ~/repos/Py2C$ python bin/nuitka --edit=bpy.types
FATAL: Error, did not find 'bpy.types' module

Ah, it's one of those:

/home/hayen/.local/lib/python3.10/site-packages/bpy/__init__.so

So, that's more or less of a duplicate. I forgot which other package has this too, but Nuitka is very confused about that, wrongfully so, of course. I can give it a quick stab, enhancing at least the detection side of things, I can imagine it might require a few corrections here and there though.

from nuitka.

kayhayen avatar kayhayen commented on June 17, 2024

From what I recall, Nuitka will work with this, but fail to find imports below, if this structure is not replicated, which it might not do. From the example though, it looks like it didn't include it at all yet. I am cleaning up code now that checks for __init__.py only.

from nuitka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.