Using Pure Python Mode with cimports

1,062 views
Skip to first unread message

kobajin

unread,
Oct 9, 2021, 3:39:30 PM10/9/21
to cython-users
Hi,

I am new to Cython, and I want to use Pure Python Mode.In reading the documentation, I'm having trouble understanding how to run this program(https://cython.readthedocs.io/en/latest/src/tutorial/pure.html?highlight=ceil#cimports).

First, I save this program as "my_ceil.py", and compile this it with "cythonize -i my_ceil.py".
The compile succeeds, but when I run it like "python -c 'import my_ceil'", I get the following error: "ModuleNotFoundError: No module named 'cython.cimports'; 'cython' is not a package". The cause is probably in the cimports section, but I don't know how to solve it.

Here are versions of my environment:
Python: 3.9
Cython: 0.29.24
Ubuntu: 20.04

Cheers.

kobajin

Stefan Behnel

unread,
Oct 10, 2021, 2:02:01 AM10/10/21
to cython...@googlegroups.com
You need to install Cython 3.0 for this feature to work.

Stefan

kobajin

unread,
Oct 10, 2021, 2:04:19 PM10/10/21
to cython-users
I was able to get the program to work, thank you!

2021年10月10日日曜日 15:02:01 UTC+9 Stefan Behnel:

Rishu Garg

unread,
Aug 31, 2022, 1:01:28 AM8/31/22
to cython-users
Hey Stephan, I'm using Cython 3.0 but I'm still getting the same error

    from cython.cimports.libc import math 
ModuleNotFoundError: 
No module named 'cython.cimports'; 'cython' is not a package

Can you please help me out?

da-woods

unread,
Aug 31, 2022, 12:50:56 PM8/31/22
to cython...@googlegroups.com
On 31/08/2022 01:24, Rishu Garg wrote:
>
>     from cython.cimports.libc import math
> ModuleNotFoundError:
> No module named 'cython.cimports'; 'cython' is not a package
>
This sounds like you might not have compiled it with Cython? Are you
just trying to run/import the .py file without compiling it first?

Rishu Garg

unread,
Sep 2, 2022, 12:54:27 AM9/2/22
to cython-users
I figured it out..

Previously, I was doing 

pip install Cython==3.0a1

I instead had to do

pip install Cython==3.0.0a11

and it fixed the problem.

Thanks everyone for your help

Matan

unread,
Jan 19, 2024, 2:50:36 PM1/19/24
to cython-users

  from cython.cimports.cython.view import array as cvarray
ModuleNotFoundError: No module named 'cython.cimports.cython'

Cython 3.0.8
Reply all
Reply to author
Forward
0 new messages