Comments (6)
As explained in the manual for distribution you should be using --standalone
or --onefile
.
from nuitka.
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.
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.
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.
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.
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)
- One-file exe work well local side, work not good on network path. HOT 3
- Failed to initialize QMediaPlayer "Not available" HOT 1
- Failed to initialize QMediaPlayer "Not available" HOT 1
- One-file .exe can't run on server (network path) with "--disable-console". HOT 7
- How to obtain the directory where the executable file is located HOT 3
- I encountered a problem with file overwriting when using LTO=yes HOT 8
- The exe file is not copied for the command --include-data-dir HOT 2
- TypeError NoneType when importing PySide6 background worker, but working when merged into main script HOT 6
- PkgResourcesPlugin.py not support python3.8?? HOT 5
- Getting stuck at yt_dlp.extractor.lazy_extrac HOT 4
- NameError when case/match dictionaries HOT 6
- Bug: No response with numpy 1.26.4, python 3.12.3, nuitka 2.3rc5 and `--standalone` HOT 2
- pyperf support HOT 3
- Working with setuptools 70.0.0 HOT 1
- crash in onefile.py: assert not os.path.exists(source_dir) HOT 5
- Why is Nuitka sometimes running slower (or not faster) than uncompiled python? HOT 9
- Hyperspy dynamic import fails when packaging an application that contains hyperspy HOT 7
- Actions: Onefile description mismatches default, needs to be easier to specify modes HOT 5
- spacy dependencies failure HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuitka.