I am running through the guide for an AI that plays flappy bird using the NEAT neural network API found here.
When I run his code downloaded from Github, it gives me the error:
"Traceback (most recent call last):
File "test.py", line 438, in <module>
run(config_path)
File "test.py", line 412, in run
config = neat.config.Config(neat.DefaultGenome, neat.DefaultReproduction,
AttributeError: module 'neat' has no attribute 'config'
The problem seems to be coming from this block of code:
def run(config_file):
"""
runs the NEAT algorithm to train a neural network to play flappy bird.
:param config_file: location of config file
:return: None
"""
config = neat.config.Config(neat.DefaultGenome, neat.DefaultReproduction,
neat.DefaultSpeciesSet, neat.DefaultStagnation,
config_file)
# Create the population, which is the top-level object for a NEAT run.
p = neat.Population(config)
# Add a stdout reporter to show progress in the terminal.
p.add_reporter(neat.StdOutReporter(True))
stats = neat.StatisticsReporter()
p.add_reporter(stats)
#p.add_reporter(neat.Checkpointer(5))
# Run for up to 50 generations.
winner = p.run(eval_genomes, 50)
# show final stats
print('\nBest genome:\n{!s}'.format(winner))
if __name__ == '__main__':
# Determine path to configuration file. This path manipulation is
# here so that the script will run successfully regardless of the
# current working directory.
local_dir = os.path.dirname(__file__)
config_path = os.path.join(local_dir, 'config-feedforward.txt')
run(config_path)
However I looked in the Neat documentation found here and it says that this attribute does in fact exist. I'm using Pycharm on a mac if that is relevant. Does anyone know where the error coming from?
I've got the same problem on the same system.
Here is how I solved it:
open PyCharms Preferences,
goto "Project: NAME_OF_PROJECT",
then open "Project Interpreter",
in there uninstall "neat" by clicking the minus button
then click the plus button and search for "neat-python" and install that.
I think PyCharms automatic Interpreter installation method gets something wrong here and installs the wrong "neat" :-P Hope this works for you!