Tais
Tais

Reputation: 1119

ImportError: No module named 'Cython'

I'm trying do from Cython.Build import cythonize and I get the message ImportError: No module named 'Cython', but I installed the Cython with the comand pip install Cython. What's wrong?

Python 3.5 Cython 0.25.2 Windows 8

Upvotes: 88

Views: 227678

Answers (11)

Alon Samuel
Alon Samuel

Reputation: 375

In my case I was trying to run pip install -r requirements.txt

And getting the error: ImportError: No module named 'Cython'.

But when checking python3 -c "import Cython; print(Cython.__version__)" it returned 3.0.11 (which tells me it exists).

What helped was to downgrade to python3.8 instead of originally using python3.11

Hope it helps!

Upvotes: 0

Anna Andreeva Rogotulka
Anna Andreeva Rogotulka

Reputation: 1626

Cython has been already installed, but somehow invisible, for python3.10 only works update

pip install wheel --upgrade

Upvotes: 10

eri
eri

Reputation: 3524

In my case insalling setuptools solves issue

pip install setuptools

Upvotes: 2

Ste
Ste

Reputation: 83

I was getting this same issue/error message when trying

pip install .

for a package. Then I tried running

python setup.py build_ext --inplace
python setup.py install

in the same environment (cython was already installed and up to date there) and it worked perfectly.

Upvotes: 4

Xiaoyu Xu
Xiaoyu Xu

Reputation: 998

Just directly install from pypi:

pip install Cython

https://pypi.org/project/Cython/

Upvotes: 85

W1ck3d
W1ck3d

Reputation: 334

I personally ran into this problem when I was trying to set up a new virtual environment. I simply installed Cython with python -m pip install Cython and then proceeded to install all the rest of my stuff I needed with python -m pip install -r requirements.txt. Once it was done, it actually uninstalled Cython for me... Why? Heck do I know... I ain't that kind of expert :<

Upvotes: 4

Charalamm
Charalamm

Reputation: 1937

The problem for me was the pip version. Running python -m pip install pip --upgrade solved the issue.

Upvotes: 12

baraa yusri
baraa yusri

Reputation: 607

Use Pip3 command:

pip3 install --upgrade cython

Upvotes: 46

Mani Rathnam
Mani Rathnam

Reputation: 11

it should be path problem. go to windows search for python idle right click idle - open file location where right click on python.exe - open file location if the module not in that location type cmd and press enter in path now install module with pip install cython it will work fine

Upvotes: 1

Pranav balu
Pranav balu

Reputation: 146

You can download the the newest Cython release from http://cython.org/ or you can directly download by clicking this link here Unpack the tarball or zip file, enter the directory, and then run:

python setup.py install

Upvotes: 6

Tais
Tais

Reputation: 1119

I reinstalled the Cython with conda and install the Microsoft Visual C++ Build Tools and it works fine.

Upvotes: 9

Related Questions