Reputation: 35
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?
Upvotes: 3
Views: 11020
Reputation: 1
This works on me: Uninstall both libraries 'neat' and 'neat-python' and then reinstall 'neat-python' pip install neat-python, current version 0.92
Upvotes: 0
Reputation: 409
I had the same issue. Mine got solved when I ran the same code after installing neat-python instead of just neat through pip. So try doing this
pip install neat-python
Also make sure that all the packages given in requirements.txt is already there in your pc.
Upvotes: 9
Reputation: 56
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!
Upvotes: 4
Reputation: 11
I had the same problem after I manually installed the libraries using "import neat", "import graphviz" and other dependencies, but after I used the requirements file the code ran fine. In console , open the folder of the project and type:
pip install -r ./requirements.txt
This solved my error.
Upvotes: 0