PyCharm Django 项目无法 运行 调试
PyCharm Django project fails to run with debugging
很长一段时间以来,我的 Windows 10 机器上都有这个奇怪的问题。尝试在 PyCharm 上调试(有时甚至不调试)启动 Django 服务器时,出现此错误:
...
pydev debugger: process 10532 is connecting
Connected to pydev debugger (build 163.8233.8)
Process finished with exit code -1073741819 (0xC0000005)
这是没有调试的样子:
"C:\Program Files (x86)\PyCharm\bin\runnerw.exe" D:\project\env\Scripts\python.exe D:/project/manage.py runserver 80
Process finished with exit code -1073741819 (0xC0000005)
最奇怪的是,如果我重新运行,有时(大约 4-6 次重新运行 中有 1 次成功)它会成功启动。没有 PyCharm.
我也无法重现这个问题
规格:Windows 10 Pro,Pycharm(这发生在 5.x 到 2016.3 的版本上)x86 和 x64 版本,Python 3.5x,Django 1.8-1 .10.x.
知道为什么会发生这种情况或如何获取有关崩溃的更多详细信息吗?
编辑 这是事件查看器报告的错误:
Faulting application name: python.exe, version: 3.5.1150.1013, time stamp: 0x566391f0
Faulting module name: ucrtbase.dll, version: 10.0.14393.0, time stamp: 0x57898db2
Exception code: 0xc0000005
Fault offset: 0x000b6d95
Faulting process ID: 0x1b30
Faulting application start time: 0x01d251286ca8ada3
Faulting application path: D:\project\env\Scripts\python.exe
Faulting module path: C:\WINDOWS\System32\ucrtbase.dll
Report ID: b23376d6-cf66-4d83-8781-cd22311e0f9e
Faulting package full name:
Faulting package-relative application ID:
编辑 2 我已经缩小了问题范围。该错误似乎源自 autoreload.py
中的 restart_with_reloader
在此语句之后:
def restart_with_reloader():
while True:
args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
if sys.platform == "win32":
args = ['"%s"' % arg for arg in args]
new_environ = os.environ.copy()
new_environ["RUN_MAIN"] = 'true'
# this line crashes the whole script
# I guess the problem arises in native code
exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
# debugger disconnects here
if exit_code != 3:
return exit_code
也许 Python 社区中有人看到过类似的东西?
我对 PyCharm 和 Django 也有同样的问题。这是由 运行 在 PyCharm 下启用 Django 的自动重新加载功能引起的。我 运行 PyCharm 作为 Jithin Pavithran 在评论中建议的管理员,问题已解决。您还可以在 PyCharm Django 服务器配置中打开 "No reload"。
tl;dr 解决方案
到 Run/Debug Configurations
对话框中的 Environment variables
添加这对:
=C:
c:\''
我已经向 JetBrains YouTrack 提交了一张票,这实际上是 Windows 如何处理命令行环境变量的问题。您可以在此处找到该问题的解决方法:https://youtrack.jetbrains.com/issue/PY-17069
JetBrains 开发评论摘录:
Guys, I just found a bug in Windows and Microsoft CRT:)
Try to add following env variable to environment variables in run config =C: = c:``
Yes, =C: is NAME and c:`` is value.
很长一段时间以来,我的 Windows 10 机器上都有这个奇怪的问题。尝试在 PyCharm 上调试(有时甚至不调试)启动 Django 服务器时,出现此错误:
...
pydev debugger: process 10532 is connecting
Connected to pydev debugger (build 163.8233.8)
Process finished with exit code -1073741819 (0xC0000005)
这是没有调试的样子:
"C:\Program Files (x86)\PyCharm\bin\runnerw.exe" D:\project\env\Scripts\python.exe D:/project/manage.py runserver 80
Process finished with exit code -1073741819 (0xC0000005)
最奇怪的是,如果我重新运行,有时(大约 4-6 次重新运行 中有 1 次成功)它会成功启动。没有 PyCharm.
我也无法重现这个问题规格:Windows 10 Pro,Pycharm(这发生在 5.x 到 2016.3 的版本上)x86 和 x64 版本,Python 3.5x,Django 1.8-1 .10.x.
知道为什么会发生这种情况或如何获取有关崩溃的更多详细信息吗?
编辑 这是事件查看器报告的错误:
Faulting application name: python.exe, version: 3.5.1150.1013, time stamp: 0x566391f0
Faulting module name: ucrtbase.dll, version: 10.0.14393.0, time stamp: 0x57898db2
Exception code: 0xc0000005
Fault offset: 0x000b6d95
Faulting process ID: 0x1b30
Faulting application start time: 0x01d251286ca8ada3
Faulting application path: D:\project\env\Scripts\python.exe
Faulting module path: C:\WINDOWS\System32\ucrtbase.dll
Report ID: b23376d6-cf66-4d83-8781-cd22311e0f9e
Faulting package full name:
Faulting package-relative application ID:
编辑 2 我已经缩小了问题范围。该错误似乎源自 autoreload.py
中的 restart_with_reloader
在此语句之后:
def restart_with_reloader():
while True:
args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
if sys.platform == "win32":
args = ['"%s"' % arg for arg in args]
new_environ = os.environ.copy()
new_environ["RUN_MAIN"] = 'true'
# this line crashes the whole script
# I guess the problem arises in native code
exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
# debugger disconnects here
if exit_code != 3:
return exit_code
也许 Python 社区中有人看到过类似的东西?
我对 PyCharm 和 Django 也有同样的问题。这是由 运行 在 PyCharm 下启用 Django 的自动重新加载功能引起的。我 运行 PyCharm 作为 Jithin Pavithran 在评论中建议的管理员,问题已解决。您还可以在 PyCharm Django 服务器配置中打开 "No reload"。
tl;dr 解决方案
到 Run/Debug Configurations
对话框中的 Environment variables
添加这对:
=C:
c:\''
我已经向 JetBrains YouTrack 提交了一张票,这实际上是 Windows 如何处理命令行环境变量的问题。您可以在此处找到该问题的解决方法:https://youtrack.jetbrains.com/issue/PY-17069
JetBrains 开发评论摘录:
Guys, I just found a bug in Windows and Microsoft CRT:) Try to add following env variable to environment variables in run config =C: = c:`` Yes, =C: is NAME and c:`` is value.