mathutils安装失败

git clone https://gitlab.com/ideasman42/blender-mathutils.git
cd blender-mathutils

python setup.py build
python setup.py install

报错:

fatal error: uchar.h: No such file or directory

fatal error: bits/libc-header-start.h: No such file or directory #include <bits/libc-header-start.h>

src/mathutils/mathutils.c: In function 'mathutils_array_hash':
src/mathutils/mathutils.c:79:24: error: incompatible type for argument 1 of '_Py_HashDouble'
   79 |     y = _Py_HashDouble(NULL, (double)(array[i++]));
      |                        ^~~~
      |                        |
      |                        void *
In file included from /root/miniconda3/envs/spad2/include/python3.9/Python.h:87,
                 from src/mathutils/mathutils.c:7:
/root/miniconda3/envs/spad2/include/python3.9/pyhash.h:10:38: note: expected 'double' but argument is of type 'void *'
   10 | PyAPI_FUNC(Py_hash_t) _Py_HashDouble(double);

分析:

这里是pip使用源代码安装的时候出现了依赖错误,第一个是依赖存在但是没有关联上,第二个是因为这多半是你所编译的项目是在64位机器上生成32位的项目,你需要安装对应的gcc 32位的库。

前两个都属于C++依赖的问题。你可以通过以下这两行代码检查相关的头文件是否在你的机器上。

如果没有安装上,运行第三行的apt get,libc6-dev是解决unicode相关的错误,gcc-multilib 是解决bits库的相关错误。

ls /usr/include/unicode/uchar.h
ls /usr/include/bits/libc-header-start.h

apt-get install libc6-dev gcc-multilib 

除了引入安装这两个依赖之外,我们还需要修改blender-mathutils下的setup.py,以便连接到相关的库。在include_dirs=[]下增加两个位置。

# setup.py文件

include_dirs = [
    "src/stubs",
    "src/blenlib",
    "src/makesdna",
    "src/makesdna",
    "/usr/include/unicode",  // 新增
    "/usr/include"  // 新增
    ] 

第三个问题,blender-mathutils/src/mathutils/mathutils.c 文件中的_Py_HashDouble函数修改为Npy_HashDouble函数,即可解决问题。

ref:https://github.com/numpy/numpy/commit/ad2a73c18dcff95d844c382c94ab7f73b5571cf3

# blender-mathutils/src/mathutils/mathutils.c 文件

# y = _Py_HashDouble(NULL, (double)(array[i++]));
y = Npy_HashDouble(NULL, (double)(array[i++]));

有些地方因机器而异哈,重要的是解决问题的思路哈,

(1)康康提示缺失的头文件存不存在,不存在想办法安装上。

(2)setup.py 上面连接上相关的文件夹

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值