如何修复:AttributeError: module ‘neat’ has no attribute ‘config’

我正在按照一个使用NEAT神经网络API玩Flappy Bird的AI指南进行操作,指南在这里可以找到 这里

当我运行从Github下载的代码时,出现了以下错误:

 "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'

问题似乎出自以下代码块:

def run(config_file):    """    运行NEAT算法以训练神经网络玩Flappy Bird。    :param config_file: 配置文件的位置    :return: None    """    config = neat.config.Config(neat.DefaultGenome, neat.DefaultReproduction,                         neat.DefaultSpeciesSet, neat.DefaultStagnation,                         config_file)    # 创建种群,这是NEAT运行的顶级对象。    p = neat.Population(config)    # 添加一个标准输出报告器以在终端显示进度。    p.add_reporter(neat.StdOutReporter(True))    stats = neat.StatisticsReporter()    p.add_reporter(stats)    #p.add_reporter(neat.Checkpointer(5))    # 运行最多50代。    winner = p.run(eval_genomes, 50)    # 显示最终统计数据    print('\nBest genome:\n{!s}'.format(winner))if __name__ == '__main__':    # 确定配置文件的路径。这里的路径操作是为了确保脚本    # 无论当前工作目录是什么都能成功运行。    local_dir = os.path.dirname(__file__)    config_path = os.path.join(local_dir, 'config-feedforward.txt')    run(config_path)

然而,我查看了NEAT文档,在这里发现这个属性确实存在。我使用的是Mac上的Pycharm,如果这有相关性的话。有人知道这个错误的来源吗?


回答:

我在相同系统上遇到了相同的问题。

这是我解决它的方法:

打开Pycharm的偏好设置,

转到”项目: 项目名称”,

然后打开”项目解释器”,

在其中通过点击减号按钮卸载”neat”

然后点击加号按钮,搜索”neat-python”并安装它。

我认为Pycharm的自动解释器安装方法在这里出了问题,安装了错误的”neat” :-P希望这对你有用!

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注