Skip to content

ImportError: dynamic module does not define init function #144

@msanders

Description

@msanders
Contributor

Hi, I'm seeing the following error when compiling modules on the latest nightly:

error[E0658]: paths of length greater than one in macro invocations are currently unstable
  --> src/lib.rs:50:3
   |
50 | #[py::modinit(_word_count)]
   |   ^^^^^^^^^^^
   |
   = help: add #![feature(proc_macro_path_invoc)] to the crate attributes to enable

Then once I fix that by adding the feature attribute, I get an error when importing e.g. python -c "import word_count" from https://github.com/PyO3/pyo3/tree/master/examples/word-count:

Python 2.7.14 (default, Apr  4 2018, 09:03:23) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import word_count
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "word_count/__init__.py", line 4, in <module>
    from ._word_count import search, search_sequential
ImportError: dynamic module does not define init function (init_word_count)

Can repro by running:

cd examples/word-count
python setup.py develop
python -c "import word_count"

(happens on both Python 2 and 3)

Any ideas?

Activity

konstin

konstin commented on May 1, 2018

@konstin
Member

Yep, it's caused by rust-lang/rust#50120 and fixed in #147, which will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @msanders@konstin

        Issue actions

          ImportError: dynamic module does not define init function · Issue #144 · PyO3/pyo3