无法让mapnik使用python3,但它与python2一起使用

时间:2013-05-09 07:07:30

标签: python mapnik

这是一篇关于在python3中安装模块的帖子。当我使用brew install python时,它会安装它为2.7。

当我使用dan建议的方法时,它的目的是直接在python3中安装它(我真的非常感谢),但哪些不起作用:

# Figure out the path to python3
PY3DIR=`dirname $(which python3)`
# And /then/ install with brew. That will have it use python3 to get its path
PATH=$PY3DIR:$PATH brew install mapnik

在python2中安装成功。所以我得到了:

For non-homebrew Python, you need to amend your PYTHONPATH like so: export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

所以我最后在python3中手动添加路径

import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')

我收到此错误:

Traceback (most recent call last):   File "<stdin>", line 1, in <module>   
File "/usr/local/lib/python2.7/site-packages/mapnik/__init__.py", line 69, in <module>
    from _mapnik import * ImportError: dlopen(./_mapnik.so, 2): Symbol not found: _PyClass_Type   Referenced from: ./_mapnik.so   
Expected in: flat namespace  in ./_mapnik.so

请帮忙,我已经花了这么多时间......

感谢!!!

1 个答案:

答案 0 :(得分:1)

Mapnik python绑定依赖于boost_python。两者都需要使用相同的python。问题很可能是自制软件提供了一瓶提升,其中包括针对python 2.7而不是python 3.x构建的boost python。