新手求助, PycharmDebug 模式报错 Traceback (most recent call last)

2019-08-06 06:33:22 +08:00
 sodadev

这个是代码,正常 run 并没有问题

i = 1 result = 1 while i <= 20:

result = result * i
if i % 5 == 0:
    print("{}:{}".format(i, result))
i = i + 1
8173 次点击
所在节点    Python
8 条回复
sodadev
2019-08-06 06:33:55 +08:00
D:\Anaconda\python.exe "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\pydevd.py" --multiproc --qt-support=pyside --client 127.0.0.1 --port 6835 --file D:/PythonDemo/code/cal.py
Traceback (most recent call last):
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 2, in <module>
from _pydevd_bundle_ext.pydevd_cython import trace_dispatch, PyDBAdditionalThreadInfo, global_cache_skips, global_cache_frame_skips
ModuleNotFoundError: No module named '_pydevd_bundle_ext'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_console_integration.py", line 2, in <module>
from code import InteractiveConsole
ImportError: cannot import name 'InteractiveConsole' from 'code' (D:\PythonDemo\code\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\pydevd.py", line 28, in <module>
from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_additional_thread_info.py", line 17, in <module>
from _pydevd_bundle.pydevd_cython_wrapper import PyDBAdditionalThreadInfo
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 32, in <module>
mod = __import__(check_name)
File "_pydevd_bundle\pydevd_cython_win32_37_64.pyx", line 139, in init _pydevd_bundle.pydevd_cython_win32_37_64
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 16, in <module>
from _pydevd_bundle.pydevd_comm import get_global_debugger
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 80, in <module>
from _pydevd_bundle import pydevd_console_integration
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_console_integration.py", line 4, in <module>
from _pydevd_bundle.pydevconsole_code_for_ironpython import InteractiveConsole
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevconsole_code_for_ironpython.py", line 305
exec code in self.locals
^
SyntaxError: Missing parentheses in call to 'exec'

Process finished with exit code 1
sodadev
2019-08-06 06:34:51 +08:00
大概意思是模块找不到的意思吗?
leishi1313
2019-08-06 06:39:16 +08:00
把你 D:\PythonDemo\code 的 code 文件夹改个名字看看
necomancer
2019-08-06 07:11:17 +08:00
是不是 code 是个 python 或者 pycharm 里的模块名啥的,结果你自己命名的文件夹是 code 所以出错了?你把文件夹名改了试试。
CHYK
2019-08-06 09:12:26 +08:00
参考这个 issue: https://github.com/Microsoft/vscode-python/issues/2836

```txt
I'am teaching students and lots of them have this error. They are newbie and they don't have lot of creativity when it comes to name files... so code.py is widely use. Might be a good idea to scan working folders to detect forbidden name and throw an alert message box when detecting names crashing. No ?
```
然而,我本地环境测试了一下,即使命名为 code.py 也没有问题。

所以我现在怀疑,你提示的这个 code 会不会和你本地的 vscode 有关系 (vscode 在命令行打开的命令就是 code)

help urself. (多试试,这类问题,貌似就是环境问题)
goofool
2019-08-06 09:45:58 +08:00
Traceback (most recent call last):
File "D:\jetbrains\PyCharm 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_console_integration.py", line 2, in <module>
from code import InteractiveConsole
ImportError: cannot import name 'InteractiveConsole' from 'code' (D:\PythonDemo\code\__init__.py)
sodadev
2019-08-06 10:14:16 +08:00
@CHYK 是文件夹名字的问题,我改了这个文件夹名字就好了。谢谢!
sodadev
2019-08-06 10:14:46 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/589367

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX