日志记录模块不适用于Python3 [英] Logging module not working with Python3

查看:98
本文介绍了日志记录模块不适用于Python3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用标准日志记录模块时遇到问题.如果我打开python2.7 shell并导入日志记录,则一切正常:

I am having issues with the standard logging module. If I open a python2.7 shell and import logging everything works fine:

$ python
>>> import logging
>>>

但是,如果我打开python3.4 shell并导入日志记录,则会出现以下错误:

But if I open a python3.4 shell and import logging I get the following error:

$ python3.4
>>> import logging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 2164, in _find_spec
File "<frozen importlib._bootstrap>", line 1940, in find_spec
File "<frozen importlib._bootstrap>", line 1916, in _get_spec
File "<frozen importlib._bootstrap>", line 1897, in _legacy_get_spec
File "<frozen importlib._bootstrap>", line 863, in spec_from_loader
File "<frozen importlib._bootstrap>", line 904, in spec_from_file_location
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/logging-0.4.9.6-py3.4.egg/logging/__init__.py", line 618
raise NotImplementedError, 'emit must be implemented '\
                         ^
SyntaxError: invalid syntax

我不知道问题是什么,而且似乎找不到其他遇到相同问题的人.

I have no idea what the problem is and can't seem to find anyone else who has had the same issue.

推荐答案

您似乎已在Python 3环境中安装了名为logging的第三方库,该库隐藏了标准库版本,并且其中一个文件包含错字.

You seem to have installed a third party library called logging in your Python 3 environment, which is hiding the standard library version, and one of its files has a typo.

这篇关于日志记录模块不适用于Python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆