notebook
notebook copied to clipboard
module 'logging' has no attribute 'Formatter'
I was working on a notebook and created a text file called logging.py for import. When I tried launching that notebook later, the kernel wouldn't start and I see this error in terminal. If I delete the text file or rename it, the problem disappears. Any idea what's going on? You should be able to reproduce the error with just an empty jupyter notebook and a text file called logging.py (see screenshot) in the same directory.
Here are the versions for jupyter, ipykernel, IPython, and traitlets: jupyter 1.0.0 py37_7 ipykernel 5.1.1 py37h39e3cac_0 ipython 7.7.0 py37h39e3cac_0 traitlets 4.3.2 py37_0
Traceback (most recent call last):
File "/Users/conradrw/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/conradrw/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/IPython/core/application.py", line 23, in <module>
from traitlets.config.application import Application, catch_config_error
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/traitlets/config/__init__.py", line 6, in <module>
from .application import *
File "/Users/conradrw/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 100, in <module>
class LevelFormatter(logging.Formatter):
AttributeError: module 'logging' has no attribute 'Formatter'
Sounds like an instance of this: https://github.com/jupyter/notebook/issues/2306#issuecomment-287771112 (although I don't think the work around reference worked).
Sounds like it's generally a good idea to always prefix custom module names in order to prevent conflicts like this.
have you solved this problem???
The solution, in this instance, is to rename or move the local file: logging.py, although there's potential for this on any number of file names.