问题描述:

Here is a post about installing a module in python3. When I use brew install python, then it installs it for 2.7.

When I use the method suggested by dan, which aimed to install it directly in python3 (who i really thank), but which didn't work :

# 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

The installation was successful but in python2. so I get:

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

so i finally add the path manually in python3 :

import sys

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

I get this error :

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

Please help, I have spent so many hours on this ...

Thanks!!!

网友答案:

The Mapnik python bindings depend on boost_python. And both need to use the same python. The problem is likely that homebrew is providing a bottle of boost which includes boost python built against python 2.7 and not python 3.x.

相关阅读:
Top