一般来说,此类问题可以通过检查 python 的版本和site-packages
文件夹的位置来解决:
❯ ipython
Python 3.9.0 | packaged by conda-forge | (default, Oct 14 2020, 22:56:29)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pyNN
In [2]: pyNN
Out[2]: <module 'pyNN' from '/usr/local/anaconda3/envs/vision_snn/lib/python3.9/site-packages/pyNN/__init__.py'>
从您的错误消息来看,您似乎更喜欢使用 anaconda(就像我一样,请参阅上面的代码)。我建议使用 environment.yml
文件。一个最小的例子是:
name: nest
channels:
- conda-forge
dependencies:
- nest-simulator
- pip
- pip:
- pyNN
然后,您使用以下命令创建虚拟环境:
conda env create -f environment.yml
这对我有用(MacOS 上的 Homebrew):
❯ ipython
Python 3.9.0 | packaged by conda-forge | (default, Oct 14 2020, 22:56:29)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pyNN.nest as sim
[INFO] [2020.11.23 17:6:53 /Users/runner/miniforge3/conda-bld/nest-simulator_1604245451948/work/nestkernel/rng_manager.cpp:217 @ Network::create_rngs_] : Creating default RNGs
[INFO] [2020.11.23 17:6:53 /Users/runner/miniforge3/conda-bld/nest-simulator_1604245451948/work/nestkernel/rng_manager.cpp:260 @ Network::create_grng_] : Creating new default global RNG
-- N E S T --
Copyright (C) 2004 The NEST Initiative
Version: nest-2.20.0
Built: Nov 1 2020 15:50:27
This program is provided AS IS and comes with
NO WARRANTY. See the file LICENSE for details.
Problems or suggestions?
Visit https://www.nest-simulator.org
Type 'nest.help()' to find out more about NEST.
CSAConnector: libneurosim support not available in NEST.
Falling back on PyNN's default CSAConnector.
Please re-compile NEST using --with-libneurosim=PATH
/usr/local/anaconda3/envs/vision_snn/lib/python3.9/site-packages/pyNN/nest/__init__.py:53: UserWarning:Unable to install NEST extensions. Certain models may not be available.
如果您需要更多详细信息,请告诉我。