Skip to content

[BUG] ImportError: ImportError: __import__ not found Python 3.7 #2557

Closed
@ObjatieGroba

Description

@ObjatieGroba

I used python_example (https://github.com/pybind/python_example) to create new package.
After installation I have

>>> import mymodule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ImportError: __import__ not found

At:
  <string>(3): <module>
  <frozen importlib._bootstrap>(222): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(914): create_module
  <frozen importlib._bootstrap>(577): module_from_spec
  <frozen importlib._bootstrap>(666): _load_unlocked
  <frozen importlib._bootstrap>(958): _find_and_load_unlocked
  <frozen importlib._bootstrap>(969): _find_and_load
  <stdin>(1): <module>

On python3.8 works perfectly

Reproducible example code

Debian10. Python 3.7

Clone and install python_example

Add this code to main.cpp

auto global = m.attr("__dict__");
py::exec(R"(
    import contextlib
)", global);

EDIT (@YannickJadoul): "After reading, remove this checklist and the template text in parentheses below."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions