nengo_gui.server.InvalidResource: Invalid resource: /local/ghost.png

I run this pacman code, but I can’t display pictures of pacman and ghost in the chrome GUI. And my Windows terminal displays this error:

nengo_gui.server.InvalidResource: Invalid resource: /local/ghost.png

Here is some of the code associated with implementing images:

agent_poly = (’<image xlink:href=“local/%s.png” x="%f" y="%f" ’
’ width="%f" height="%f" transform=“translate(%f,%f) rotate(%f)”/>’
% (agent.typeBody, -s/2, -s/2, s, s, agent.x+0.5, agent.y+0.5, direction - 90))
agents.append(agent_poly)

And I’m also pretty sure I have these two pictures in my folder
Does anyone know how to solve this problem?

Ummm, I’m having a similar problem with my Ubuntu machine, and anyone can help me?

Hi @mingchenliu,

I am unable to run the code from the repository without some heavy modifications to the code to make it run in Python 3 (the code seems to be written for Python 2). If you have modified the code to get it to run in your environment, can you post the modified code here so that I can test exactly what you are running?

That said, it looks like the error you are encountering is that the Python code is unable to find the path to the images. The easiest way to fix this is to modify the code in pacman_world.py and provide the full path (not the absolute path) to the local directory. I think the line you’ll need to change is this one.

Oh, @xchoo thinks,
I did make some modified, and uploaded here.
I modify the code in pacman_wprld.py and provide the full path to the local directory, as you said, the error is gone. But still no pictures of pacman and ghost are shown in the chrome GUI. As the figure shown:

Hi, @xchoo ,
I remember other problem. When I used the GUI in chrome, the nengo.PES() function is seem haven’t the pre_tau partemeter? I received such as error: TypeError: init() got an unexpected keyword argument ‘pre_tau’. But, there is no such error when I used PyCharm. In addition, I took a closer look at the nengo.PES() function in here, it does have this parameter.

nengo: 3.0.0
nengo-gui: 0.4.7

Is this a bug?

Hmmm. It looks like the Nengo server instance has a limited set of folders it can access, which is for security reasons. I found one method to make it work. First, you have to find the location of your NengoGUI installation. You can do this by starting a Python shell in your Python environment, and then doing:

import nengo_gui
print(nengo_gui.__file__)

As an example, on my linux installation the path is:

/home/xchoo/miniconda3/envs/nengo-gui/lib/python3.7/site-packages/nengo_gui/

And on my windows installation the path is:

D:\xchoo\miniconda3\envs\nengo-gui\Lib\site-packages\nengo_gui\

Next, copy the contents of the local directory (i.e., pacman.png and ghost.png) into the NengoGUI’s static folder (i.e., ...\miniconda3\envs\nengo-gui\Lib\site-packages\nengo_gui\static).

Then, modify the pacman_world.py code and change local to static in the href link:

agent_poly = (
    r'<image xlink:href="static/%s.png" x="%f" y="%f" '
    r' width="%f" height="%f" transform="translate(%f,%f) rotate(%f)"/>'
    % (
        agent.typeBody,
        -s / 2,
        -s / 2,
        s,
        s,
        agent.x + 0.5,
        agent.y + 0.5,
        direction - 90,
    )

No, this is not a bug. The pre_tau parameter was rename pre_synapse in Nengo 2.8.0. It looks like you are using Nengo 3.0.0, in which case you should rename pre_tau to pre_synapse where ever you encounter it.