编译GTSAM库的python版本,python报错

idc@trumanxxliu-LB0:~/idc_catkin_ws/gtsam-4.0.3/build_py$ make python-install
[  0%] Generating core.cpp
Compiling /home/idc/idc_catkin_ws/gtsam-4.0.3/build_py/cython/gtsam_eigency/core.pyx

Error compiling Cython file:
------------------------------------------------------------
...
cimport cython
cimport numpy as np
       ^
------------------------------------------------------------

core.pxd:2:8: Compiler crash in AnalyseDeclarationsTransform

File 'ModuleNode.py', line 124, in analyse_declarations: ModuleNode(core.pxd:1:0,
    is_pxd = True)
File 'Nodes.py', line 431, in analyse_declarations: StatListNode(core.pxd:1:0)
File 'Nodes.py', line 431, in analyse_declarations: StatListNode(core.pxd:2:8)
File 'Nodes.py', line 7942, in analyse_declarations: CImportStatNode(core.pxd:2:8,
    as_name = u'np',
    is_absolute = True,
    module_name = u'numpy')

Compiler crash traceback from this point on:
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Compiler/Nodes.py", line 7942, in analyse_declarations
    self.module_name, self.pos, relative_level=0 if self.is_absolute else -1)
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Compiler/Symtab.py", line 1274, in find_module
    module_name, relative_to=relative_to, pos=pos, absolute_fallback=absolute_fallback)
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 211, in find_module
    pxd_pathname = self.find_pxd_file(qualified_name, pos, sys_path=need_pxd)
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 250, in find_pxd_file
    pxd = self.search_include_directories(qualified_name, ".pxd", pos, sys_path=sys_path)
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 296, in search_include_directories
    suffix, pos, include)
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Utils.py", line 41, in wrapper
    res = cache[args] = f(*args)
  File "/home/idc/.local/lib/python2.7/site-packages/Cython/Compiler/Main.py", line 816, in search_include_directories
    path = os.path.join(dirname, dotted_filename)
  File "/usr/lib/python2.7/posixpath.py", line 73, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 10: ordinal not in range(128)
cython/gtsam_eigency/CMakeFiles/cythonize_eigency_core_pyx2cpp.dir/build.make:60: recipe for target 'cython/gtsam_eigency/core.cpp' failed
make[3]: *** [cython/gtsam_eigency/core.cpp] Error 1
make[3]: *** 正在删除文件“cython/gtsam_eigency/core.cpp”
CMakeFiles/Makefile2:35535: recipe for target 'cython/gtsam_eigency/CMakeFiles/cythonize_eigency_core_pyx2cpp.dir/all' failed
make[2]: *** [cython/gtsam_eigency/CMakeFiles/cythonize_eigency_core_pyx2cpp.dir/all] Error 2
CMakeFiles/Makefile2:35046: recipe for target 'cython/CMakeFiles/python-install.dir/rule' failed
make[1]: *** [cython/CMakeFiles/python-install.dir/rule] Error 2
Makefile:12716: recipe for target 'python-install' failed
make: *** [python-install] Error 2

因为之前装了gtsam4.0.3的python版本,突然不能用了,决定重新编译安装,
cmake文件改了option(GTSAM_INSTALL_CYTHON_TOOLBOX “Enable/Disable installation of Cython toolbox” ON),然后编译,发现这个错误,还以为gtsam冲突,因为装了个其他版本的c++的编译,最后定位在这句

  File "/usr/lib/python2.7/posixpath.py", line 73, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 10: ordinal not in range(128)

不太敢直接改文件,以为是cython问题,最后没想到真的是python2里面的问题,离谱。
直接改这个文件拉到了,在最前面添加如下:

import sys 
reload(sys) 
sys.setdefaultencoding('utf8') 

重新编译即可,不改这个文件的方法没测试过

参考:
http://blog.sina.com.cn/s/blog_6b1ed4fb01019d4n.html
https://www.cnblogs.com/RDaneelOlivaw/p/8439677.html

你可能感兴趣的:(slam,python,深度学习,开发语言)