17

Why does Cython not want to work ? I've pip installed it and when I try to import it, it just won't work.

I'm using MacOS Version 10.12.6 (16G29).

➡️ Desktop pip3 install Cython
Collecting Cython
Using cached https://files.pythonhosted.org/packages/e1/97/7e98410329c8a629d1.1de13377280a5b43bfcede6e05b95397609fae1f4c/Cython-0.29.3-cp37-cp37m-macosx.10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Installing collected packages: Cython
Successfully installed [email protected]
➡️ Desktop
➡️ Desktop
➡️ Desktop
➡️ Desktop python3.7
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)
[Clang 6.0 Cclang-600.0.57)] on darwin
Type “help”, “copyright”, “credits” or “License” for more information.
>>
>>
>>> import Cython
Traceback (most recent call last):
File "<stdiro", line 1, in <module>
ModuleNotFoundError: No module named "Cython*
>>
>>
>>> import cython
Traceback (most recent call last):
File "<stdiro", line 1, in <module>
ModuleNotFoundError: No module named ‘cython*
>>
0

1 Answer 1

30

This is possible if you have multiple versions of Python installed try:

python3.7 -m pip install cython

use which pip3 to check where it was installing the package previously


Update: OP used python3.7, if you have a different alias or a different version, you should use that instead. This is obviously installation dependent.

3
  • 3
    It has to happen a good number of time before you systematically check your version.
    – Benoît P
    Jan 27, 2019 at 16:54
  • @AbhimanyuAryan OP used python3.7, if you have a different alias or a different version, you should use that instead.
    – Benoît P
    Mar 31, 2020 at 19:04
  • I had the same issue after upgrading to a newer Python minor version. (So I never had two versions of Python3 installed at once, but had leftover packages from before the upgrade.) Running the above command with a plain python3 fixed it for me. Apr 19, 2020 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.