Search code examples
pythonpycharm

Debugging in Pycharm gives "AttributeError: module 'numbers' has no attribute 'Number'"


Why does the Pycharm show AttributeError: module 'numbers' has no attribute 'Number' when I debug a program, but no error happened if I run it?

Traceback (most recent call last):
  File "E:\Program Files\JetBrains\PyCharm 2019.1\helpers\pydev\pydevd.py", line 15, in <module>
    from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PY34_OR_GREATER, IS_PY36_OR_GREATER, IS_PYCHARM, get_thread_id, \
  File "E:\Program Files\JetBrains\PyCharm 2019.1\helpers\pydev\_pydevd_bundle\pydevd_constants.py", line 169, in <module>
    from _pydev_imps._pydev_saved_modules import thread
  File "E:\Program Files\JetBrains\PyCharm 2019.1\helpers\pydev\_pydev_imps\_pydev_saved_modules.py", line 21, in <module>
    import xmlrpc.client as xmlrpclib
  File "C:\Users\A\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 135, in <module>
    from decimal import Decimal
  File "C:\Users\A\AppData\Local\Programs\Python\Python37\lib\decimal.py", line 3, in <module>
    from _decimal import *
AttributeError: module 'numbers' has no attribute 'Number'

Solution

  • Check your project directories if you have same module name number since the python standard library also includes a module with that name.

    So change your module name or you can try this:

    1. Go to Run/Edit/Debug Configurations
    2. For the current file, From the 'Configuration', 'Logs' Tab, Select Configuration Tab (Default)
    3. Uncheck both 'Add content to PYTHONPATH' and 'Add source to PYTHONPATH'