日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

est.java 2 错误 找不到符号_找不到Cython/Python符号PyString\u Typ

發(fā)布時間:2023/12/10 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 est.java 2 错误 找不到符号_找不到Cython/Python符号PyString\u Typ 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我試圖調(diào)用Cython的C++代碼,并遵循official guide。在

但是,當(dāng)在python中導(dǎo)入已編譯的模塊時,我得到以下錯誤。在---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

in ()

----> 1 import rect

ImportError: /home/userName/estCppLibrary/rect.so: undefined symbol: PyString_Type

我必須補(bǔ)充,我沒有管理員權(quán)限,必須在~/.local/lib本地安裝Cython。在擁有sudo權(quán)限和默認(rèn)路徑的私人筆記本上,我的代碼可以正常工作。在

這是我的密碼。在

^{pr2}$

-#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);

};

}

-#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;

}

}

-#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(&width, &height)

return width, height

def move(self, dx, dy):

self.c_rect.move(dx, dy)

總結(jié)

以上是生活随笔為你收集整理的est.java 2 错误 找不到符号_找不到Cython/Python符号PyString\u Typ的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。