import dolfin, undefined symbol: Py_InitModule4

Asked by Paul Constantine

First:
$ python -c"import dolfin"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/paulcon/local/lib/python2.7/site-packages/dolfin/__init__.py", line 16, in <module>
    import cpp
  File "/home/paulcon/local/lib/python2.7/site-packages/dolfin/cpp/__init__.py", line 40, in <module>
    exec("import %s" % module_name)
  File "<string>", line 1, in <module>
  File "/home/paulcon/local/lib/python2.7/site-packages/dolfin/cpp/common.py", line 30, in <module>
    _common = swig_import_helper()
  File "/home/paulcon/local/lib/python2.7/site-packages/dolfin/cpp/common.py", line 26, in swig_import_helper
    _mod = imp.load_module('_common', fp, pathname, description)
ImportError: /home/paulcon/local/lib/python2.7/site-packages/dolfin/cpp/_common.so: undefined symbol: Py_InitModule4

Second:
$ nm _common.so | grep Py_InitModule4
                 U Py_InitModule4

Third:
$ ldd _common.so | grep python
 libpython2.7.so.1.0 => /share/apps/python/2.7.3/lib/libpython2.7.so.1.0 (0x00002b2e89a59000)

Fourth:
$ nm /share/apps/python/2.7.3/lib/libpython2.7.so | grep Py_InitModule4
000000000010aa10 T Py_InitModule4_64

Question:
Did I miss something? A "64" flag somewhere along the line? Is it something with swig? I installed swig (2.0.9) from source.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Paul Constantine
Solved:
Last query:
Last reply:
Revision history for this message
Johannes Ring (johannr) said :
#1

Perhaps DOLFIN was built with a different Python than what you are using at runtime? If so, rebuild DOLFIN and make sure CMake picks up the correct Python by specifying PYTHON_INCLUDE_DIR and PYTHON_LIBRARY during configuration.

Revision history for this message
Paul Constantine (paul-g-constantine) said :
#2

Yep. That was it. CMake had picked up the wrong include directory for python. Thanks!