Why i have Cython magic name error after linux reinstallation?

Viewed 63

I am facing a problem with Cython. I have a jupyter notebook with a lot of computation. I wrote Python + Cython code a few days ago. Everything worked. But yesterday I reinstalled my linux, installed anaconda3 and tried to run my code. It stopped working) I think the problem is in the anaconda settings, but I don't know how to solve it. My problem is the same as that one. But my terminal is using Python3.8.3, so i don't know what to do. Here is some sample code that doesn't work.

%load_ext Cython
import Cython

%%cython
cdef class Test:
    cdef text
    
    def __init__(self):
        self.text = 'Hello!'
        
    cdef print_text(self):
        print(self.text)
        
    cdef set_text(self, text):
        self.text = text

t = Test()

NameError Traceback (most recent call last) in ----> 1 t = Test() NameError: name 'Test' is not defined


def do():
    print('Do')

do()

Do


%%cython

def do1():
    print('Do1')

do1()

NameError Traceback (most recent call last) in ----> 1 do1() NameError: name 'do1' is not defined

So the cells with %%cython magic is not working. I tried the def, cdef, cpdef like the guy from link. But it's still not working.

0 Answers
Related