typedef struct{
const char* name;
int basicsize;
int itemsize;
unsigned int flags;
#undef slots //这里取消slots宏定义
PyType_Slot *slots; /* terminated by slot==0. */
#define slots Q_SLOTS //这里恢复slots宏定义与QT中QObjectDefs.h中一致
} PyType_Spec;
#undef slots
PyType_Slot *slots;
#define slots Q_SLOTS
C++调用Python总是出现NULL的问题,
原因一、项目中用到了第三方模块比如pandas 你没安装
原因二、Python文件存放的路径找不到
原因三、机器安装了多个Python环境混乱了
安装第三方模块建议用国内镜像
以下是例子:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
注意:新版 Ubuntu 要求使用https源。
例如:pip3 install -i https://pypi.doubanio.com/simple/ 包名
临时使用:#
可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas,这样就会从清华的镜像去安装pandas库。
推荐使用清华的 我用了很好用