ImportError: dynamic module does not define init function (PyInit_ycm_core)

407 views
Skip to first unread message

Diego Amor

unread,
Mar 7, 2016, 1:04:49 PM3/7/16
to ycm-users

Hi, today after update ycm give me his error ImportError: dynamic module does not define init function (PyInit_ycm_core)
i make install.py with clang and without with the same result.

* vim --version
  VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:47)

*Last commit
  9569bb4223711fde89739ea77e915dda77b115c2

* Traceback:
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/russo/dot-files/dot-vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 183, in <module>
    Main()
  File "/home/russo/dot-files/dot-vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 160, in Main
    if not CompatibleWithCurrentCoreVersion():
  File "/home/russo/dot-files/dot-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/server_utils.py", line 50, in CompatibleWithCurrentCoreVersion
    import ycm_core
ImportError: dynamic module does not define init function (PyInit_ycm_core)

* server_stderr.log:
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/russo/dot-files/dot-vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 183, in <module>
    Main()
  File "/home/russo/dot-files/dot-vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 160, in Main
    if not CompatibleWithCurrentCoreVersion():
  File "/home/russo/dot-files/dot-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/server_utils.py", line 50, in CompatibleWithCurrentCoreVersion
    import ycm_core
ImportError: dynamic module does not define init function (PyInit_ycm_core)

Thank you.

Ben Jackson

unread,
Mar 24, 2016, 5:34:00 PM3/24/16
to ycm-users
This is answered on the YouCompleteMe README.md

Diego Amor

unread,
Apr 20, 2016, 9:20:55 AM4/20/16
to ycm-users

Yes, sorry... RTFM!!!  for me! :P

Copy text from README:
### I get `ImportError` exceptions that mention `PyInit_ycm_core` or `initycm_core`

These errors are caused by building the YCM native libraries for Python 2 and
trying to load them into a Python 3 process (or the other way around).

For instance, if building for Python 2 but loading in Python 3:

```

ImportError: dynamic module does not define init function (PyInit_ycm_core)
```

If building for Python 3 but loading in Python 2:

```
ImportError: dynamic module does not define init function (initycm_core)
```

Setting the `g:ycm_server_python_interpreter` option to force the use of a
specific Python interpreter for `ycmd` is usually the easiest way to solve the
problem. Common values for that option are `/usr/bin/python` and
`/usr/bin/python3`.

kissg

unread,
Apr 22, 2016, 12:59:15 PM4/22/16
to ycm-users
Actually, the so-called solution doesn't solve my problem. Then I think about "Why not build it for python3?" So I changed the header of install.py to "#!/usr/bin/python3" and also modified "python" to "python3" in the code part. After rebuilding, the error doesn't show any more. What's more, YCM works! 

So if you use python3, you may build ycm for python3 instead of python2.
Reply all
Reply to author
Forward
0 new messages