这是一篇关于在 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
请帮忙,我在这上面花了很多时间......
谢谢!!!