No module named Cython and Running cythonize failed [Fix]

Updated on May 15, 2020

I have been using Websockify to allow the browser to connect to any application or service on a Linux machine. This involves setting up Websockify server that translates the WebSockets to the normal socket and enables the traffic to follow between the client and the server. Installation of Websockify is simple, but the process ended with an error “No module named Cython. RuntimeError: Running cythonize failed!“. And remember that the Websockify binary is not available for PPC64LE architecture (like most of the packages), so I ended up compiling it from the source.

Note:

I’m using the command python3.6, because Websockify requires Python version 3 and above. If your default Python version is greater than 3, then you just need to use python command instead of python3.6.

The installation is started using the below command.

#python3.6 setup.py install
[....]
run_build = parse_setuppy_commands()
Cythonizing sources
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_mt19937.pyx
Traceback (most recent call last):
  File "/tmp/easy_install-n7o_lgt3/numpy-1.18.4/tools/cythonize.py", line 61, in process_pyx
    from Cython.Compiler.Version import version as cython_version
ModuleNotFoundError: No module named Cython
[...]
RuntimeError: Running cythonize failed!

How to fix No module named Cython

We need to install Cython package depending on the version of Python installed on the system as below:

#pip3.6 install Cython
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3.6 install --user` instead.
Collecting Cython
  Downloading https://files.pythonhosted.org/packages/9b/24/3416df8ae5962b09f6b522ad6d61e711dadb57816a6e4e76c3b99732f3c5/Cython-0.29.17-py2.py3-none-any.whl (971kB)
    100% |████████████████████████████████| 972kB 961kB/s
Installing collected packages: Cython
Successfully installed Cython-0.29.17

That’s it. As the Cython package is installed,  I went on to install Websockify successfully.

Was this article helpful?

Related Articles

Leave a Comment