Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NEAT-Python not finding Visualize.py

So recently I have found about a NEAT algorithm and wanted to give it a try using NEAT-Python(not sure if this is even the correct source :| ). So I created my virtual environment activated it and installed the neat-python using pip in the VE. When I then tried to run one of the examples from their GitHub page it threw an error like this:

ImportError: No module named visualize

So I checked my source files, and actually the neat-python doesn't include the visualize.py script, however it is in their GitHub repository. I then tried to add it myself by downloading just the visualize.oy script dragging it inside my VE and adding it to all the textfiles the NEAT brought with it, like the installed-filex.txt etc. However it still threw the same error.

I'm still fairly new to VE and GitHub so please don't be too hard on me :] thanks in advance.

-Jorge

like image 945
J.Paravicini Avatar asked Jan 19 '17 21:01

J.Paravicini


1 Answers

I think you could simply copying the visualize.py into the same directory as the script you are running.

If you wanted it in your lib/site-packages directory so you could import it with the neat module:

copy visualize.py into lib/site-packages/neat/ and modify __init__.py to add the line import neat.visualize as visualize. Delete the __pycache__ directory. Make sure you have modules installed: Numpy, GraphViz, and Matplotlib. When you've done the above, you should be able to import neat and access neat.visualize.

I don't recommend doing this though for several reasons:

  1. Say you wanted to update your neat module. Your visualize.py file is technically not part of the module. So it wouldn't be updated along with your neat module.
  2. the visualize.py file seems to be written in the context of the examples as opposed to being for general use with the module, so contextually, it doesn't belong there.
  3. At some point in the future, you might also forget that this wasn't a part of the module, but your code acts as if it was part of the API. So your code will break in some other neat installation.
like image 129
fpes Avatar answered Oct 27 '22 12:10

fpes