简体   繁体   English

如何修复:AttributeError:模块“整洁”没有属性“配置”

[英]How to fix: AttributeError: module 'neat' has no attribute 'config'

I am running through the guide for an AI that plays flappy bird using the NEAT neural network API found here .我正在浏览使用 NEAT 神经网络 API AI 玩飞扬小鸟的指南。

When I run his code downloaded from Github, it gives me the error:当我运行他从 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'

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.但是,我查看了此处找到的 Neat 文档,它说该属性确实存在。 I'm using Pycharm on a mac if that is relevant.如果相关的话,我在 Mac 上使用 Pycharm。 Does anyone know where the error coming from?有谁知道错误来自哪里?

I had the same issue.我遇到过同样的问题。 Mine got solved when I ran the same code after installing neat-python instead of just neat through pip.当我在安装了整洁的python之后运行相同的代码而不是仅仅通过 pip 运行相同的代码时,我的问题得到了解决。 So try doing this所以尝试这样做

pip install neat-python pip 安装整洁的python

Also make sure that all the packages given in requirements.txt is already there in your pc.还要确保 requirements.txt 中给出的所有包都已经在你的电脑中了。

I've got the same problem on the same system.我在同一个系统上遇到了同样的问题。

Here is how I solved it:这是我解决它的方法:

open PyCharms Preferences,打开 PyCharms 首选项,

goto "Project: NAME_OF_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.然后单击加号按钮并搜索“neat-python”并安装它。

I think PyCharms automatic Interpreter installation method gets something wrong here and installs the wrong "neat":-P Hope this works for you!我认为 PyCharms 自动解释器安装方法在这里出错并安装了错误的“整洁”:-P 希望这对你有用!

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.在使用“import quiet”、“import graphviz”和其他依赖项手动安装库后,我遇到了同样的问题,但在使用需求文件后,代码运行良好。 In console, open the folder of the project and type:在控制台中,打开项目的文件夹并输入:

pip install -r./requirements.txt pip install -r./requirements.txt

This solved my error.这解决了我的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误,模块整洁没有属性配置 - error, module neat has no attribute config AttributeError: 模块 &#39;config&#39; 没有属性 &#39;Config&#39; - AttributeError: module 'config' has no attribute 'Config' 如何修复 AttributeError: &#39;module&#39; 对象没有属性 &#39;function&#39;? - How to fix AttributeError: 'module' object has no attribute 'function'? 如何修复“AttributeError:‘module’对象没有属性‘x’”? - how to fix "AttributeError: 'module' object has no attribute 'x' "? 如何修复AttributeError:模块&#39;testing2&#39;没有属性&#39;printPackage&#39;? - How to fix AttributeError: module 'testing2' has no attribute 'printPackage'? 如何在wfastcgi中修复“ AttributeError:模块没有属性&#39;wsgi&#39;” - How to fix “AttributeError: module has no attribute 'wsgi' ” in wfastcgi 如何修复 AttributeError:模块“tensorflow”没有属性“ConfigProto” - How can I fix AttributeError: module 'tensorflow' has no attribute 'ConfigProto' 如何修复 AttributeError:模块“requests.sessions”没有属性“post” - How to Fix AttributeError: module 'requests.sessions' has no attribute 'post' 如何修复 AttributeError:模块“magpylib”没有属性“源” - How to Fix AttributeError: module 'magpylib" has no attribute 'source' 如何修复“AttributeError:模块&#39;keras.backend&#39;没有属性..” - How to fix "AttributeError: module 'keras.backend' has no attribute.."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM