如何解决此错误IOError:[Errno 2]没有这样的文件或目录:' logging.yaml' ?

时间:2017-12-05 14:13:18

标签: python yaml

我正在尝试使用python库" google_news_crawler"可以通过" pip install google_news_crawler"安装。当我运行它的示例代码时。

google_news_crawler --datastore=ES --feed="http://news.google.com/news?cf=all&ned=en_bw&output=rss&topic=t&sort=newest"

它给我一个这样的错误:

-HP-Notebook:~$ google_news_crawler --datastore=ES --feed="http://news.google.com/news?cf=all&ned=en_bw&output=rss&topic=t&sort=newest"
Traceback (most recent call last):
  File "/usr/local/bin/google_news_crawler", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/google_news_crawler/google_news_crawler.py", line 46, in main
    setup_logging(args['--log-config'])
  File "/usr/local/lib/python2.7/dist-packages/google_news_crawler/google_news_crawler.py", line 36, in setup_logging
    with open(fname) as f:
IOError: [Errno 2] No such file or directory: 'logging.yaml'

我真的不知道什么是&#39; logging.yaml&#39;文件以及如何解决此错误。

谢谢

1 个答案:

答案 0 :(得分:0)

cd /usr/local/lib/python2.7/dist-packages/google_news_crawler/
sudo touch logging.yaml
sudo vi logging.yaml

将内容下方的粘贴复制到该文件中:

disable_existing_loggers: false
formatters:
  default:
    format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s'
    #datefmt: '%Y-%m-%d %H:%M:%S'
handlers:
  console:
    class: logging.StreamHandler
    formatter: default
loggers:
  google_news_crawler.gnc:
    level: DEBUG
  elasticsearch:
    level: ERROR
  elasticsearch.trace:
    handlers: null
root:
  handlers: [console]
  level: WARNING
version: 1