Cython/Python - Symbols not found PyString_Type
<p>I am trying to call C++ code from cython and am following the <a href="http://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html" rel="nofollow">official guide</a>.</p>

<p>However, when importing the compiled module in python, I get the following error.</p>

<pre><code>---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
&lt;ipython-input-1-ba16f97c2145&gt; in &lt;module&gt;()
----&gt; 1 import rect

ImportError: /home/userName/estCppLibrary/rect.so: undefined symbol: PyString_Type
</code></pre>

<p>I must add, that I have no admin permissions and had to install Cython locally in <code>~/.local/lib</code>. On my private laptop with sudo permissions and the default paths my code works.</p>

<p>Here is my code.</p>

<pre><code>#setup.py

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

ext = Extension(
    "rect",
    sources = ["rect.pyx", "Rectangle.cpp"],
    language = "c++",
    include_dirs=["~/.local/include"],
    library_dirs=["~/.local/lib"]
    )

setup(ext_modules = cythonize(ext))
</code></pre>

<p>-</p>

<pre><code>#Rectangle.h

namespace shapes {
    class Rectangle {
    public:
        int x0, y0, x1, y1;
        Rectangle();
        Rectangle(int x0, int y0, int x1, int y1);
        ~Rectangle();
        int getArea();
        void getSize(int* width, int* height);
        void move(int dx, int dy);
    };
}
</code></pre>

<p>-</p>

<pre><code>#Rectangle.cpp


namespace shapes {

Rectangle::Rectangle() { }

    Rectangle::Rectangle(int X0, int Y0, int X1, int Y1) {
        x0 = X0;
        y0 = Y0;
        x1 = X1;
        y1 = Y1;
    }

    Rectangle::~Rectangle() { }

    int Rectangle::getArea() {
        return (x1 - x0) * (y1 - y0);
    }

    void Rectangle::getSize(int *width, int *height) {
        (*width) = x1 - x0;
        (*height) = y1 - y0;
    }

    void Rectangle::move(int dx, int dy) {
        x0 += dx;
        y0 += dy;
        x1 += dx;
        y1 += dy;
    }


}
</code></pre>

<p>-</p>

<pre><code>#rect.pyx

# distutils: language = c++
# distutils: sources = Rectangle.cpp

cdef extern from "Rectangle.h" namespace "shapes":
    cdef cppclass Rectangle:
        Rectangle() except +
        Rectangle(int, int, int, int) except +
        int x0, y0, x1, y1
        int getArea()
        void getSize(int* width, int* height)
        void move(int, int)

cdef class PyRectangle:
    cdef Rectangle c_rect      # hold a C++ instance which we're wrapping
    def __cinit__(self, int x0, int y0, int x1, int y1):
        self.c_rect = Rectangle(x0, y0, x1, y1)
    def get_area(self):
        return self.c_rect.getArea()
    def get_size(self):
        cdef int width, height
        self.c_rect.getSize(&amp;width, &amp;height)
        return width, height
    def move(self, dx, dy):
        self.c_rect.move(dx, dy)
</code></pre>