You are not logged in.

#1 2016-03-22 20:50:30

geo909
Member
Registered: 2008-09-07
Posts: 309

[SOLVED] Problem when using python (and cython) with sagemath

Hi,

I am using sagemath often. This ships with its own version of python, which is also bundled with cython. Sometimes I write sage programs, but I also use cythonized python definitions to make things faster. For example, I put my definitions in a file named 'mydefs.pyx', and I create a file ''setup.py' as follows:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize

setup(
        ext_modules = cythonize("mydefs.pyx")
        )

Then I will run

sage -python setup.py build_ext --inplace

in order to cythonize mydefs.pyx. I use `sage -python` in order to use the python that is built-in to sage (this is essential in order to run those programs in sage later).

This has been working on my school's server and my old computer, where sage is installed. I now got a new computer, installed sage, and tried to do the same. I got:

[jorge@alavanja CAsearch]$ sage -python setup.py build_ext --inplace
Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from Cython.Build import cythonize
ImportError: No module named Cython.Build

I googled around and I haven't found a solution. Can somebody point me to the right direction? Why this error message?

Thanks a lot in advance

Last edited by geo909 (2016-03-23 13:50:43)

Offline

#2 2016-03-22 22:51:45

arojas
Developer
From: Spain
Registered: 2011-10-09
Posts: 2,316

Re: [SOLVED] Problem when using python (and cython) with sagemath

How did you install sage?

Offline

#3 2016-03-22 22:54:46

geo909
Member
Registered: 2008-09-07
Posts: 309

Re: [SOLVED] Problem when using python (and cython) with sagemath

arojas wrote:

How did you install sage?

I installed it from the community repos:
https://www.archlinux.org/packages/?name=sagemath

Offline

#4 2016-03-23 07:43:11

arojas
Developer
From: Spain
Registered: 2011-10-09
Posts: 2,316

Re: [SOLVED] Problem when using python (and cython) with sagemath

geo909 wrote:
arojas wrote:

How did you install sage?

I installed it from the community repos:
https://www.archlinux.org/packages/?name=sagemath

Then you're wrong in your assumption that it ships its own version of Python and cython. The sagemath package in community is compiled against system libs. In particular, if you want to use it in cython code you must install the cython2 package. And "sage -python" just calls the system python2.

Offline

#5 2016-03-23 13:50:24

geo909
Member
Registered: 2008-09-07
Posts: 309

Re: [SOLVED] Problem when using python (and cython) with sagemath

arojas wrote:
geo909 wrote:
arojas wrote:

How did you install sage?

I installed it from the community repos:
https://www.archlinux.org/packages/?name=sagemath

Then you're wrong in your assumption that it ships its own version of Python and cython. The sagemath package in community is compiled against system libs. In particular, if you want to use it in cython code you must install the cython2 package. And "sage -python" just calls the system python2.

Thanks a lot! I was sure, for some reason, that sage came bundled with its own python/cython..

Anyway, I installed cython2 and everything works. Thanks again!

Offline

Board footer

Powered by FluxBB