On Nov 19, 2009, at 1:57 PM, Jorge E. ´Sanchez Sanchez wrote: > Hi dear sage-support group: > > I was working a Differential equations problem with few elements > in some regular 3D-mesh which needed not too much calculations but I > am upgrading it to a bigger system. Then I shall need to do some > calculations using cython, so my first task is to build the simplest > Hello world example to understand how to proceed with my > implementation. > But I think something is missing in my Cython installation or > perhaps I am doing something wrong, because I cannot accomplish to > build even this simplest cython example. I am using sage 4.1 in a > Karmic Ubuntu 9.10. > > In my first try I just follow the directions in the Cython's manual; > first save a file with just the line: > > print "hello world" > > as hello.pyx and then from the command line: > > python setup.py build_ext --inplace > > where the setup.py file is the same as in the manual. > > But I get the message: > > Traceback (most recent call last): > File "setup.py", line 3, in <module> > from Cython.Distutils import build_ext > ImportError: No module named Cython.Distutils
That is because Cython is not installed into your system Python, but the Sage one. Try running sage -python setup.py build_ext --inplace > within sage: > sage -sh OK, this should be the same as running sage -python ... > > running build_ext > cythoning helloworld.pyx to helloworld.c > building 'helloworld' extension > gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict- > prototypes -fPIC -I/opt/sage/local/include/python2.6 -c helloworld.c > -o build/temp.linux-x86_64-2.6/helloworld.o > gcc -pthread -shared build/temp.linux-x86_64-2.6/helloworld.o -o > helloworld.so > > it finally got built the file helloworld.c and compile and link them > until reach helloworld.so > > but when I try the next step: > import helloworld > > /usr/bin/python: /opt/sage/local/lib/libz.so.1: no version > information available (required by /usr/bin/python) > Traceback (most recent call last): > File "/usr/lib/command-not-found", line 8, in <module> > import CommandNotFound > ImportError: No module named CommandNotFound I have never heard of this error. Sounds like libz was somehow miscompiled. Did you get your sage as a binary, or build from source? What happens if you do "import zlib" directly? > My next try was following the directions in: > http://behnel.de/cython200910/talk.html [...] > it seems that I don't have the option --embed, to create an embedded > main() function. Sounds like you're using an old version of Sage (and Cython), the -- embedd option was added this spring. In fact, if it looks like 4.1.1 was the first to include this new feature. > If I ignore this and proceed: > cython hw.py > I get the hw.c and from here: > > gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict- > prototypes -fPIC -I/opt/sage/local/include/python2.6 \ > /opt/sage/local/lib/libpython2.6.a -o hw hw.c -lpthread -lm > -lutil -ldl > > (may be I exagerate a little with all the compilation parameters, > but I get a > > /usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib/crt1.o: In > function `_start': > /build/buildd/eglibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:109: > undefined reference to `main' > /tmp/ccLFKVfV.o: In function `__Pyx_AddTraceback': > /home/george/hw.c:995: undefined reference to `PyString_FromString' > > ... > ... > a bunch of more similar complains and finally > /home/george/hw.c:612: undefined reference to `PyErr_SetObject' > collect2: ld returned 1 exit status > > so I need the embedded main(), could you tell me how I can proceed? > (I am sorry if I extended too much). To use the --embed option, you'll need to upgrade to a newer version of Sage. Then try the above and it may just work (if not, let us know). - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org