question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] ModuleNotFoundError: no module named 'logging.config'

See original GitHub issue

🐛 Bug

To reproduce

following tutorial: https://cli.dev/docs/tutorial/logging

** Minimal Code/Config snippet to reproduce **

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import hydra

log = logging.getLogger(__name__)


@hydra.main()
def my_app(_cfg):
    log.info('info level message')
    log.debug('debug level message')

** Stack trace/error message **

Traceback (most recent call last):
  File "logging.py", line 4, in <module>
    import logging
  File "$HOME/workspace/hydra_test/logging.py", line 5, in <module>
    import hydra
  File "$HOME/miniconda3/lib/python3.7/site-packages/hydra/__init__.py", line 2, in <module>
    from . import utils
  File "$HOME/miniconda3/lib/python3.7/site-packages/hydra/utils.py", line 2, in <module>
    import logging.config
ModuleNotFoundError: No module named 'logging.config'; 'logging' is not a package

Expected Behavior

executes successfully (without package import error)

System information

0.90

Linux 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
omrycommented, Oct 21, 2019

Oh. Your file is called logging.py, I think it’s confusing python and shadowing the logging package. I am 99% sure this is it, sure enough to close this 😃 reopen if renaming it does not fix the problem.

0reactions
omrycommented, Oct 21, 2019

Also environment.yaml from: also attach conda env export > environment.yaml and the output of:

$ python
>>> import hydra
>>> import logging
>>> import logging.config

Try reproducing with a fresh conda env.

conda create -n hydra_test python=3.7
conda activate hydra_test
pip install hydra==0.9.0
...

There is a new version of Hydra (0.10.0) but I don’t think it should make a difference, so install the same version to make things clearer. if it works in the clean env, it’s either some conflict with something else you have in your conda env - or maybe you are not actually running the python version you think you are.

In any case, I will need minimal repro instructions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModuleNotFoundError: No module named 'logging-config'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'logging-config' How to remove the Mod.
Read more >
python 3.x - ImportError: No module named 'logging.handlers ...
Solution is rename the file to anything else like logging-test.py and be sure, that there is no other file like logging.py. I spent...
Read more >
no module named 'logging' error : PY-6097 - YouTrack
Packages are not show for Jython: no module named 'logging' error. Instead error is shown: Traceback (innermost last): File ...
Read more >
logging.config — Logging configuration — Python 3.11.1 ...
Starts up a socket server on the specified port, and listens for new configurations. If no port is specified, the module's default DEFAULT_LOGGING_CONFIG_PORT ......
Read more >
ImportError: no module named 'logging'
Re: ImportError: no module named 'logging' ... It wouldn't be available - MicroPython is a subset. Not all libraries can be implemented.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found