如何在 Ubuntu 18.04 上的 Python3 中安装 nest

How to install nest in Python3 on Ubuntu 18.04

在遵循 Nest 模拟器的 Ubuntu/Debian installation instructions 后,我只能在 python2.x 中导入 nest 模块,而不是 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)

默认安装使用默认 Python 版本编译,该版本在 Ubuntu 中仍然是 2。 要使用 Python 3, 运行:

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

在文档中提到 here

注意:不要忘记清除构建文件夹以避免出现问题