python-3.xnest-simulator

How to install nest in Python3 on Ubuntu 18.04


After following the Ubuntu/Debian installation instructions for the Nest simulator I can only import the nest module in python2.x, not python3.x

$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nest/lib/python2.7/site-packages/nest/__init__.py", line 26, in <module>
    from . import ll_api      # noqa
  File "/nest/lib/python2.7/site-packages/nest/ll_api.py", line 72, in <module>
    from . import pynestkernel as kernel      # noqa
ImportError: dynamic module does not define module export function (PyInit_pynestkernel)

Solution

  • The default install compiles with the default Python version which is still 2 in Ubuntu. To use Python 3, run:

    cmake -Dwith-python=3 -DCMAKE_INSTALL_PREFIX:PATH=</install/path> </path/to/NEST/src>
    

    Mentioned here in the doc.

    NB: don't forget to clear the build folder to avoid issues