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.

cythonized modules in zipapp (.pyz) cant be imported

See original GitHub issue

I’ve a module cythonized in mydir. Running python3 mydir/__main__.py works fine, but if I create a .pyz with zipapp but after that python3 mydir.pyz fail with message ImportError.

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "machine.pyz/__main__.py", line 5, in <module>
ImportError: No module named 'ads.main'

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
robertwbcommented, Mar 31, 2021

This is not a restriction with Cython, but with zipimport, and any fix would have to be on that side.

1reaction
codewarrior0commented, Nov 8, 2016

zipapp merely leverages Python’s built-in zipimport facility; from the zipimport docs we find:

ZIP import of dynamic modules (.pyd, .so) is disallowed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: Cannot import Cython module - Stack Overflow
I found my mistake. After trying a million things, I figured it has nothing to do with my setup.py or my source code....
Read more >
zipapp — Manage executable Python zip archives — Python ...
The main argument should take the form “pkg.module:callable” and the archive will be run by importing “pkg.module” and executing the given callable with...
Read more >
zipapps - PyPI
Distribute zipapp with embedded python. Use as a requirements zip path, or some venv usages. import sys;sys.path.insert(0, 'app.pyz') ...
Read more >
Release notes for Python 3.5.4
bpo-23491: Added a zipapp module to support creating executable zip file archives of Python code. Registered ".pyz" and ".pyzw" extensions on Windows for ......
Read more >
Importing a cython module from another module
so for each file with success, but I cannot import/link bitarray (it is a C extension itself, the module has a __init__.py and...
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