cython hello world

I used cython for the first time. I stumbled on various things just by moving a simple module, so I will leave it as a memo.

Environment: Mac OS El Capitan

Build procedure

I referred to Learning Cython Programming --Second Edition. The code is here.

In the book, I made a .pyx file, but I tried using a normal .py file.

cython -o helloworld.c helloworld.py

Then compile.

gcc -g -O2 -fpic -c helloworld.c -o helloworld.o `python-config --cflags`
gcc -g -O2 -shared -o helloworld.so helloworld.o `python-config --libs`

When I imported the .so file created in this way, a segmentation fault occurred. An issue was reported on github for this issue, and I changed the options passed to gcc and the error did not occur.

gcc -g -O2 -fpic -c helloworld.c -o helloworld.o `python-config --cflags`
gcc -g -O2 -shared -o helloworld.so helloworld.o `python-config --ldflags`

Also, in cython documentation, distutils The procedure for using is described, and I thought it was easier.

Symbol not found: _PyUnicodeUCS4_Compare

Now that the practice is over, I built the module I'm targeting with cython. When I tried using it, I got an ImportError error called Symbol not found: _PyUnicodeUCS4_Compare.

Refer to this article, remove python 2.7.12 installed with virtualenv, and try running it with python on the Mac system. I did.

Is it a matter of which module to link with at build time? Unlike plain python, cython is troublesome.

Recommended Posts

cython hello world
Hello world
Pymacs hello world
web2py memo: Hello World
hello world with ctypes
RabbitMQ Tutorial 1 ("Hello World!")
Hello, World with Docker
Hello World on Django
Hello world with flask
Draw hello world with mod_wsgi
Hello World with Flask + Hamlish
Until hello world with zappa
Programming language in "Hello World"
Hello World in GO language
Hello World (beginners) on Django
Python starting with Hello world!
Let's do "Hello World" in 40 languages! !!
Introduction to TensorFlow --Hello World Edition
Hello world! (Minimum Viable Block Chain)
[Note] Hello world output with python
cout << "Hello, World! \ N" in python
Hello World in Flask [Appropriate memo]
Code: 2 "Hello World" in "Choregraphe-Python script"
Hello World! By QPython with Braincrash
Python #Hello World for super beginners
Introduction to Ansible Part 1'Hello World !!'
[Python] Web application from 0! Hands-on (2) -Hello World-
Hello World and face detection with opencv-python 4.2
Hello World with Raspberry Pi + Minecraft Pi Edition
How to build Hello, World on #Nix
Hello world instead of localhost in Django
Flask tutorial (from installation to hello world)
How to display Hello world in python
Hello World! By QPython with Brainfu * k
Hello World and face detection with OpenCV 4.3 + Python
Hello World with gRPC / go in Docker environment
Python 1 person study session: 1st "Running Python ~" Hello world ""
From Kivy environment construction to displaying Hello World
Say hello to the world with Python with IntelliJ
Hello World with nginx + uwsgi + python on EC2
Flask Hello World cannot be displayed on VPS
Create a one-file hello world application with django
First python ① Environment construction with pythonbrew & Hello World !!
Create a "Hello World" (HTTP) server with Tornado
To myself as a Django beginner (3)-Hello world! ---