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.

Does not work with Nuitka

See original GitHub issue

Nuitka creates a single executable out of your python code.

I’ve used platformdirs in a project of mine called mcrpc. The code itself runs fine, but the executable created with Nuitka spits out this error:

λ ./mcrpc-linux                                                                  
Traceback (most recent call last):
  File "/tmp/.mount_mcrpc-h4h3HH/mcrpc.py", line 14, in <module>
  File "/tmp/.mount_mcrpc-h4h3HH/platformdirs/__init__.py", line 33, in <module platformdirs>
  File "/tmp/.mount_mcrpc-h4h3HH/platformdirs/__init__.py", line 29, in _set_platform_dir_class
  File "importlib.py", line 127, in import_module
ModuleNotFoundError: No module named 'platformdirs.unix'

It spits out a similar error on windows: ModuleNotFoundError: No module named 'platformdirs.windows'

Is there anything that can be done on platformdirs’ side to help it work well with Nuitka? You can try using the executables from v1.2.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ofekcommented, Jan 22, 2022

The issue is the dynamic imports https://github.com/platformdirs/platformdirs/blob/2.4.1/src/platformdirs/__init__.py#L20-L33

Changing to actual import statements and executing the logic outside of that function should fix it.

0reactions
txtsdcommented, Feb 19, 2022

@gaborbernat GLORIOUS!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · Nuitka/Nuitka - GitHub
Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, and...
Read more >
Nuitka not compiling an exe with nuitka --recurse-all hello.py ...
I am trying to create a simple exe through nuitka so that I can run it on my laptop without Python needing to...
Read more >
User Manual - Nuitka
No information is available for this page.
Read more >
Nuitka - Wikipedia
Nuitka is a source-to-source compiler which compiles Python code to C source code, applying some compile-time optimizations in the process such as constant ......
Read more >
Ubuntu Manpage: nuitka - the Python compiler
This means not a folder, but a compressed executable is created and used. ... Otherwise Nuitka can use what you run Nuitka with...
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