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.

Cython crashes when trying to build extension from __init__.py

See original GitHub issue

I’ve noticed this on some occasions. When Cython tries to build an extension module with distutils, it crashes and spits out an error like this. Here is me trying to compile a test __init__ file from the command line.

C:\Users\You>cythonize -i -3 __init__.py
running build_ext
building 'You.__init__' extension
creating C:\Users\tmpo_kxxv5_\Release
creating C:\Users\tmpo_kxxv5_\Release\Users
creating C:\Users\tmpo_kxxv5_\Release\Users\You
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python37\include -Ic:\python37\include "-IC
:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Fil
es (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x8
6)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows
Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\includ
e\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17
763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt"
/TcC:\Users\You\__init__.c /FoC:\Users\tmpo_kxxv5_\Release\Users\You\__init__.ob
j
__init__.c
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /n
ologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c
:\python37\libs /LIBPATH:c:\python37\PCbuild\amd64 "/LIBPATH:C:\Program Files (x
86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\
Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x8
6)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\W
indows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows
Kits\10\lib\10.0.17763.0\um\x64" /EXPORT:PyInit___init__ C:\Users\tmpo_kxxv5_\Re
lease\Users\You\__init__.obj /OUT:C:\Users\You\__init__.cp37-win_amd64.pyd /IMPL
IB:C:\Users\tmpo_kxxv5_\Release\Users\You\__init__.cp37-win_amd64.lib

LINK : error LNK2001: unresolved external symbol PyInit___init__
C:\Users\tmpo_kxxv5_\Release\Users\You\__init__.cp37-win_amd64.lib : fatal error
 LNK1120: 1 unresolved externals

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\
x86_amd64\\link.exe' failed with exit status 1120

Not only that, but it creates pyd fieles when then crash the program if something tries to import them because there empty. I believe the error is caused by PyInit___init__, which probably is aukward enough to cause the compiler to throw an error. The contents of the init file is: ‘’‘testing file’‘’ pass

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
Keithcat1commented, Jul 1, 2020

Must’ve been from pip. I got my current cython version from the command: “pip install cython==3.0a5” Anyway, it works now.

1reaction
Keithcat1commented, May 31, 2019

Thanks! I guess I need to download Cython from Github and install that if I want to compipe init

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does adding an __init__.py change Cython build_ext
This results in an incorrect name (incompatible with your project layout due to a missing folder) and causes setuptools to crash. And is...
Read more >
When C extensions crash: easier debugging for your Python ...
When C extensions crash: easier debugging for your Python application · 1. Tracebacks on segfaults with faulthandler · 2. Enable detailed ...
Read more >
Properly unloading an embedded cython-based extension
This issue is seemingly general to python extensions which give unpredictable behavior on reload: cython extensions thankfully return a harmless None on reload, ......
Read more >
Cython Changelog — Cython 3.0.0a11 documentation
Relative imports failed in compiled __init__.py package modules. ... A new Cython build option --cython-compile-minimal was added to compile only a smaller ...
Read more >
TypeError: 'NoneType' object is not callable : PY-52137
In addition, the code execution fails for me, even if I run it out of PyCharm. I am wondering if this is specific...
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