I am stumbled across Nengo and was intrigued; however, when I went to use the first example (below), it did not seem to have imported the Network module. I have tried both the 3.0 and the latest git repository – is the intro documentation out dated? I am running it using Visual Studio Code + Anaconda and have tried it both in Jupyter and using a standard .py file.
import nengo
import numpy as np
import matplotlib.pyplot as plt
with nengo.Network() as net:
sin_input = nengo.Node(output=np.sin)
# A population of 100 neurons representing a sine wave
sin_ens = nengo.Ensemble(n_neurons=100, dimensions=1)
nengo.Connection(sin_input, sin_ens)
# A population of 100 neurons representing the square of the sine wave
sin_squared = nengo.Ensemble(n_neurons=100, dimensions=1)
nengo.Connection(sin_ens, sin_squared, function=np.square)
# View the decoded output of sin_squared
squared_probe = nengo.Probe(sin_squared, synapse=0.01)
with nengo.Simulator(net) as sim:
sim.run(5.0)
plt.plot(sim.trange(), sim.data[squared_probe])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 import nengo
2 import numpy as np
3 import matplotlib.pyplot as plt
4
5 with nengo.Network() as net:
e:\xampp\htdocs\othermind\nengo.py in
4 import matplotlib.pyplot as plt
5
----> 6 with nengo.Network() as net:
7 sin_input = nengo.Node(output=np.sin)
8 # A population of 100 neurons representing a sine wave
AttributeError: module 'nengo' has no attribute 'Network'
Hello and welcome! Try renaming your nengo.py script to something else. Python doesn’t like it when you try to import a library with the same name as an existing file in the current working directory.
Right I’ve had this problem a few times in the past when I start back using python after not using it for a while.
Now I am getting a weird message in large bold html font that is probably more to do with my Jupyter instance:
TypeError: Cannot read property ‘__esModule’ of undefined at
in p in Unknown in ForwardRef in span in div in div in div in t in div in div in div in div in div in t in h in t in div in div in div in t in main in div in t in h in f
That’s a very strange error. I’m not even sure what I’m looking at. Is this being printed out somewhere in the command line, jupyter UI, or inside of a notebook? Are you able to run any notebooks at all (even just one that prints hello world)? My guess without extra information is the jupyter install is broken or depending on some wrong combination of package versions. If that’s the case I’d recommend using conda to create a clean environment.
If I run it in the console it works (or at least the simulation works) but doesn’t show anything.
I saw some errors when I installing things (I installed first the normal one, uninstalled that, then installed the git version, then uninstalled that and reinstalled the normal version). My guess is something got messed up with the cache because the errors, I believe, were related to the cache. I’ll get rid of everything and clear the cache and try installing it again tomorrow.
Hi @otherrealm,
Once you have uninstalled Nengo, before reinstalling it, I would recommend testing to see that your Jupyter environment still runs (regular) python code correctly. If that tests okay, then you should be good to reinstall Nengo. If not, you’ll probably have to reinstall Jupyter.
As a side note, if you don’t already use Conda, it’s a great tool to help manage Python installations. It’s fairly easy to use, and makes it easy to wipe and redo python environments without the fear of messing up the system python installation.