1

I've installed pyNN and nest but I can't import it. When I run it in the terminal it works, and the program starts. However, if I try to import inside python:

cd ~
python
import nest

It raises an error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.7/site- 
packages/pyNN/nest/__init__.py", line 16, in <module>
    import nest
ModuleNotFoundError: No module named 'nest'

How can I fix it?

Edit: I installed pyNN and nest via homebrew (on macOS Mojave).

TerhorstD
  • 265
  • 1
  • 2
  • 12
Arthu83
  • 11
  • 2
  • Can you describe (in the question, not in a comment) how exactly you installed the module `nest`, i.e. what command you have used? Maybe [this answer](https://stackoverflow.com/a/56451612/10669875) explains your issue. – wovano Jun 17 '19 at 19:02
  • Possible duplicate of [ModuleNotFoundError: No module named 'pyaudio' (Windows)](https://stackoverflow.com/questions/56449253/modulenotfounderror-no-module-named-pyaudio-windows) – wovano Jun 17 '19 at 19:18
  • I'm on mac. I think the issue is with Mojave since the directories in other answered questions of people having the same problem are different. – Arthu83 Jun 17 '19 at 21:09
  • This does not seem to be duplicate of above question then. I'm not familiar with Mac or homebrew, so I can't help you with that. Did you already read [this installation instructions](http://neuralensemble.org/docs/PyNN/installation.html#installing-nest-and-pynest)? I hope it helps. Good luck. – wovano Jun 17 '19 at 22:17

1 Answers1

1

In general such problems can be resolved by checking the version of python and the location of the site-packages folder :

❯ 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'>

From your error message, it appears you rather use anaconda (like I do, see my code above). I would suggest to use an environment.yml file. A minimal example is:

name: nest
channels:
    - conda-forge
dependencies:
   - nest-simulator
   - pip
   - pip:
     - pyNN

You then create a virtual environment using:

conda env create -f environment.yml

That worked for me (Homebrew on MacOS):

❯ 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.

Tell me if you need more details.

meduz
  • 3,903
  • 1
  • 28
  • 40