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.

cythonize failed in installation

See original GitHub issue

Hi,

I meet wit the following problem when I install from source:

Cythonizing sources
Processing numpy/random/mtrand/mtrand.pyx
Traceback (most recent call last):
  File "/share/apps/bin/cython", line 8, in <module>
    main(command_line = 1)
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 709, in main
    result = compile(sources, options)
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 684, in compile
    return compile_multiple(source, options)
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 657, in compile_multiple
    context = options.create_context()
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 582, in create_context
    self.cplus, self.language_level, options=self)
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 75, in __init__
    from . import Builtin, CythonScope
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/CythonScope.py", line 5, in <module>
    from .UtilityCode import CythonUtilityCode
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/UtilityCode.py", line 3, in <module>
    from .TreeFragment import parse_from_strings, StringParseContext
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/TreeFragment.py", line 17, in <module>
    from .Visitor import VisitorTransform
  File "Cython/Compiler/Visitor.py", line 15, in init Cython.Compiler.Visitor (/share/apps/src/cython/Cython/Compiler/Visitor.c:19407)
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/ExprNodes.py", line 4244, in <module>
    class SliceIndexNode(ExprNode):
  File "/share/apps/lib/python2.7/site-packages/Cython/Compiler/ExprNodes.py", line 4396, in SliceIndexNode
    "SliceObject", "ObjectHandling.c", context={'access': 'Get'})
  File "Cython/Compiler/Code.py", line 286, in Cython.Compiler.Code.UtilityCodeBase.load (/share/apps/src/cython/Cython/Compiler/Code.c:9181)
  File "Cython/Compiler/Code.py", line 525, in Cython.Compiler.Code.TempitaUtilityCode.__init__ (/share/apps/src/cython/Cython/Compiler/Code.c:15550)
  File "Cython/Compiler/Code.py", line 517, in Cython.Compiler.Code.sub_tempita (/share/apps/src/cython/Cython/Compiler/Code.c:15269)
  File "/share/apps/lib/python2.7/site-packages/Cython/Tempita/__init__.py", line 4, in <module>
    from ._tempita import *
  File "Cython/Tempita/_tempita.py", line 36, in init Cython.Tempita._tempita (/share/apps/src/cython/Cython/Tempita/_tempita.c:31807)
  File "/share/apps/lib/python2.7/cgi.py", line 50, in <module>
    import mimetools
  File "/share/apps/lib/python2.7/mimetools.py", line 6, in <module>
    import tempfile
  File "/share/apps/lib/python2.7/tempfile.py", line 35, in <module>
    from random import Random as _Random
  File "/share/apps/src/numpy-1.9.3/numpy/random/__init__.py", line 99, in <module>
    from .mtrand import *
ImportError: No module named mtrand
--fast-fail mtrand.c mtrand.pyx
Traceback (most recent call last):
  File "/share/apps/src/numpy-1.9.3/tools/cythonize.py", line 200, in <module>
    main()
  File "/share/apps/src/numpy-1.9.3/tools/cythonize.py", line 196, in main
    find_process_files(root_dir)
  File "/share/apps/src/numpy-1.9.3/tools/cythonize.py", line 188, in find_process_files
    process(cur_dir, fromfile, tofile, function, hash_db)
  File "/share/apps/src/numpy-1.9.3/tools/cythonize.py", line 162, in process
    processor_function(fromfile, tofile)
  File "/share/apps/src/numpy-1.9.3/tools/cythonize.py", line 73, in process_pyx
    raise Exception('Cython failed')
Exception: Cython failed
Traceback (most recent call last):
  File "setup.py", line 251, in <module>
    setup_package()
  File "setup.py", line 239, in setup_package
    generate_cython()
  File "setup.py", line 191, in generate_cython
    raise RuntimeError("Running cythonize failed!")
RuntimeError: Running cythonize failed!

I am using

Cython version 0.24.0a0

Many thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

9reactions
maniteja123commented, Jan 1, 2016

Hi, I remember facing this issue when installing scipy, do try installing cython using pip or easy_install using easy_install cython or pip install cython. Hope it helps.

1reaction
rgommerscommented, Jan 1, 2016

From the traceback it looks like tempfile somehow manages to confuse numpy.random with stdlib random:

File "/share/apps/lib/python2.7/tempfile.py", line 35, in <module>
  from random import Random as _Random
File "/share/apps/src/numpy-1.9.3/numpy/random/__init__.py", line 99, in <module>
  from .mtrand import *

Can you try just from the command line:

$ cython numpy/random/mtrand/mtrand.pyx

If that fails as well, something may be broken in Cython. Next step then would be to check that the problem disappears if you go back to Cython 0.23.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

build scipy error cythonize failed - python - Stack Overflow
I'm trying to build scipy and I get a RuntimeError: $sudo python setup.py build ...
Read more >
No module named Cython and Running cythonize failed [Fix]
This article will help you to solve the error No module named Cython if encountered during websockify installation on PPC64LE with CentOS7.
Read more >
Error installing Scipy from repository with latest Cython installed
python setup.py build, I found the following error: Exception: Cython failed. Traceback (most recent call last): File "setup.py", line 229, in <module>
Read more >
Build Scipy Error Cythonize Failed - ADocLib
When installing scipy through pip with : pip install scipy Pip fails to build scipy and throws the following error: Cleaning up. ModuleNotFoundError:...
Read more >
Jetson Nano Developer Kit
Running setup.py bdist_wheel for numpy … error ... raise RuntimeError(“Running cythonize failed!”) RuntimeError: Running cythonize failed!
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