在 Pycharm 中调试给出“AttributeError: module 'numbers' has no attribute 'Number'”

问题描述 投票:0回答:1

为什么Pycharm调试程序时显示

AttributeError: module 'numbers' has no attribute 'Number'
,但运行却没有错误?

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'
python pycharm
1个回答
5
投票

检查您的项目目录是否有相同的模块名称

number
,因为Python标准库也包含具有该名称的模块。

所以更改你的模块名称或者你可以尝试这个:

  1. 转到运行/编辑/调试配置
  2. 对于当前文件,从“配置”、“日志”选项卡中,选择“配置”选项卡(默认)
  3. 取消选中“将内容添加到 PYTHONPATH”和“将源添加到 PYTHONPATH”
© www.soinside.com 2019 - 2024. All rights reserved.