【问题标题】:How to solve this error IOError: [Errno 2] No such file or directory: 'logging.yaml' ?如何解决此错误 IOError: [Errno 2] No such file or directory: 'logging.yaml' ?
【发布时间】:2018-05-19 05:40:22
【问题描述】:

我正在尝试使用 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'

我真的不知道什么是“logging.yaml”文件以及如何解决这个错误。

谢谢

【问题讨论】:

标签: python yaml


【解决方案1】:
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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2019-03-25
    • 1970-01-01
    • 2021-06-26
    相关资源
    最近更新 更多