Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'logging' has no attribute 'Formatter' #4892

Open
conradry opened this issue Sep 16, 2019 · 3 comments
Open

module 'logging' has no attribute 'Formatter' #4892

conradry opened this issue Sep 16, 2019 · 3 comments

Comments

@conradry
Copy link

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'

view

@kevin-bates
Copy link
Member

Sounds like an instance of this: #2306 (comment) (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.

@sidingli
Copy link

have you solved this problem???

@kevin-bates
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants