Cynthia GS
Cynthia GS

Reputation: 522

Build error for Basemap in Python 3.7 on MacOS -- coming from Cython?

I've been desperately trying to reinstall Basemap for Python 3.7 and when doing sudo python3 setup.py build, I keep on running into this long list of errors:

_proj.c:7421:21: error: no member named 'exc_type' in 'struct _ts'
    *type = tstate->exc_type;
            ~~~~~~  ^
_proj.c:7422:22: error: no member named 'exc_value' in 'struct _ts'; did you mean 'curexc_value'?
    *value = tstate->exc_value;
                     ^~~~~~~~~
                     curexc_value
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:237:15: note: 'curexc_value' declared here
    PyObject *curexc_value;
              ^
_proj.c:7423:19: error: no member named 'exc_traceback' in 'struct _ts'; did you mean 'curexc_traceback'?
    *tb = tstate->exc_traceback;
                  ^~~~~~~~~~~~~
                  curexc_traceback
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
    PyObject *curexc_traceback;
              ^
_proj.c:7435:24: error: no member named 'exc_type' in 'struct _ts'
    tmp_type = tstate->exc_type;
               ~~~~~~  ^
_proj.c:7436:25: error: no member named 'exc_value' in 'struct _ts'; did you mean 'curexc_value'?
    tmp_value = tstate->exc_value;
                        ^~~~~~~~~
                        curexc_value
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:237:15: note: 'curexc_value' declared here
    PyObject *curexc_value;
              ^
_proj.c:7437:22: error: no member named 'exc_traceback' in 'struct _ts'; did you mean 'curexc_traceback'?
    tmp_tb = tstate->exc_traceback;
                     ^~~~~~~~~~~~~
                     curexc_traceback
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
    PyObject *curexc_traceback;
              ^
_proj.c:7438:13: error: no member named 'exc_type' in 'struct _ts'
    tstate->exc_type = type;
    ~~~~~~  ^
_proj.c:7439:13: error: no member named 'exc_value' in 'struct _ts'; did you mean 'curexc_value'?
    tstate->exc_value = value;
            ^~~~~~~~~
            curexc_value
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:237:15: note: 'curexc_value' declared here
    PyObject *curexc_value;
              ^
_proj.c:7440:13: error: no member named 'exc_traceback' in 'struct _ts'; did you mean 'curexc_traceback'?
    tstate->exc_traceback = tb;
            ^~~~~~~~~~~~~
            curexc_traceback
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
    PyObject *curexc_traceback;
              ^
_proj.c:7483:24: error: no member named 'exc_type' in 'struct _ts'
    tmp_type = tstate->exc_type;
               ~~~~~~  ^
_proj.c:7484:25: error: no member named 'exc_value' in 'struct _ts'; did you mean 'curexc_value'?
    tmp_value = tstate->exc_value;
                        ^~~~~~~~~
                        curexc_value
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:237:15: note: 'curexc_value' declared here
    PyObject *curexc_value;
              ^
_proj.c:7485:22: error: no member named 'exc_traceback' in 'struct _ts'; did you mean 'curexc_traceback'?
    tmp_tb = tstate->exc_traceback;
                     ^~~~~~~~~~~~~
                     curexc_traceback
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
    PyObject *curexc_traceback;
              ^
_proj.c:7486:13: error: no member named 'exc_type' in 'struct _ts'
    tstate->exc_type = local_type;
    ~~~~~~  ^
_proj.c:7487:13: error: no member named 'exc_value' in 'struct _ts'; did you mean 'curexc_value'?
    tstate->exc_value = local_value;
            ^~~~~~~~~
            curexc_value
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:237:15: note: 'curexc_value' declared here
    PyObject *curexc_value;
              ^
_proj.c:7488:13: error: no member named 'exc_traceback' in 'struct _ts'; did you mean 'curexc_traceback'?
    tstate->exc_traceback = local_tb;
            ^~~~~~~~~~~~~
            curexc_traceback
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
    PyObject *curexc_traceback;
              ^
15 warnings and 15 errors generated.
error: command 'clang' failed with exit status 1

At this point, I'm pretty sure the issue is coming from Cython, with the wrong version of Cython being called, as pointed out here: https://github.com/matplotlib/basemap/issues/414, but I have no idea how to "regenerate the C sources". I have tried cythonize --force src/_geoslib.pyx but I get back that cythonize does not exist. Any idea about what could be going on and on how to fix it?

Note: Basemap works fine if I do sudo python setup.py build, which calls Python 2.7 instead of 3.7.

Upvotes: 4

Views: 2024

Answers (2)

tigertang
tigertang

Reputation: 457

I meet the same problem when trying to install kmc2 on python 3.8.12 with mac catalina. I fix it by git clone the kmc2 repository and manually cythonize the pyx file before setup install.

Upvotes: 1

Chris
Chris

Reputation: 932

I had the same problem. As DavidW said in the comment first I needed to install cython. pyshp was missing also:

pip3 install cython
pip3 install pyshp

However swig was not installed either. So I needed:

brew install swig

I then had to install basemap via pip:

 pip3 install -U git+https://github.com/matplotlib/basemap.git

Note: I had already manually installed geos-3.3.3, so I am not sure the pip install via github would have installed that also

Upvotes: 3

Related Questions