Pycharm Django调试真的很慢
Pycharm Django Debugging is really slow
我有一个中等大小的网站,但 PyCharm 需要大约 30 秒才能启动 Runserver 并准备好 运行 应用程序。如果我 "Run" 应用程序而不是 "Debugging",则启动只需大约 3 秒。
我可以做哪些事情来加快代码更改和调试周期。
我正在使用带有 16Gb RAM 的不错的 MBP。所以硬件不是问题。
我已从项目中排除 /media 文件。
我没有任何其他会导致索引问题的大量文件
我同时使用 Postgres 和 Mongo 数据库。
我正在 运行ning Django 1.7 + 十几个软件包,例如:
dj-static==0.0.6
django-annoying==0.8.1
django-appconf==1.0.1
django-bootstrap-form==3.2
django-bootstrap-pagination==1.5.1
django-compressor==1.5
django-extensions==1.5.5
django-filter==0.10.0
django-guardian==1.2.5
django-storages-redux==1.2.3
django-widget-tweaks==1.3
djangorestframework==3.1.2
django-jinja==1.4.1
这是调试输出:
/Users/user1/.virtualenvs/env-test/bin/python "/Applications/PyCharm 4.5 EAP.app/Contents/helpers/pydev/pydevd.py" --multiproc --save-signatures --client 127.0.0.1 --port 64097 --file /Users/user1/gitroot/website1/manage.py runserver 0.0.0.0:8000 --verbosity 2
Connected to pydev debugger (build 141.1245)
pydev debugger: process 63926 is connecting
pydev debugger: process 63954 is connecting
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
June 03, 2015 - 09:08:52
Django version 1.7.7, using settings 'myproject.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
更新:
由于此 post Pycharm 具有使用 Cython 作为解释器的能力。我认为这在一定程度上改善了情况。我也转而使用 Runserverplus,我认为它 运行s 更快。
好吧,调试器很慢,您对此无能为力。除非你绝对需要它,否则不要使用调试器(即你正在解决一个特别难以捉摸的错误)。
我能想到的只有一件事可以加速 PyCharm 的调试器,那就是关闭 "Collect run-time types information for code insight" 设置(位于文件 > 设置 > 构建、执行、部署下> Python调试器)。
对我来说,当我记得我 启用了调试器以收集类型信息时,问题得到了改善。
点击 Ctrl-Shift-A
或在 Settings > Build, Execution, Deployment > Python Debugger
下搜索 collect run-time types information for code insight
取消选中复选框并点击 apply
看看这是否有帮助
我运行PyCharm Community 5.0.1
我注意到原始 poster 的调试输出不包含有关 cython 的消息。我来到这个 post 是因为我无法弄清楚为什么我的 pycharm 调试这么慢,但后来我意识到在我的调试输出中有一个加速调试器的建议。
"<some-path-to-python>/python" "/Applications/PyCharm.app/Contents/helpers/pydev/setup_cython.py" build_ext --inplace
我希望人们已经尝试过了。我想这个答案是为全世界的非输出读者准备的。
需要对这些进行实验,取自Jetbrain blog:
- delete all breakpoints
- turn off tracing exceptions
- no runtime type insights
但也请考虑禁用 Django 模型检查等以加快速度。
我使用了一个补丁来加速测试用例,比 运行 快 10 倍。
所以,如果你做 TDD,函数没有视图那么重。让你快速解决bug。
我有一个中等大小的网站,但 PyCharm 需要大约 30 秒才能启动 Runserver 并准备好 运行 应用程序。如果我 "Run" 应用程序而不是 "Debugging",则启动只需大约 3 秒。
我可以做哪些事情来加快代码更改和调试周期。 我正在使用带有 16Gb RAM 的不错的 MBP。所以硬件不是问题。
我已从项目中排除 /media 文件。 我没有任何其他会导致索引问题的大量文件 我同时使用 Postgres 和 Mongo 数据库。 我正在 运行ning Django 1.7 + 十几个软件包,例如:
dj-static==0.0.6
django-annoying==0.8.1
django-appconf==1.0.1
django-bootstrap-form==3.2
django-bootstrap-pagination==1.5.1
django-compressor==1.5
django-extensions==1.5.5
django-filter==0.10.0
django-guardian==1.2.5
django-storages-redux==1.2.3
django-widget-tweaks==1.3
djangorestframework==3.1.2
django-jinja==1.4.1
这是调试输出:
/Users/user1/.virtualenvs/env-test/bin/python "/Applications/PyCharm 4.5 EAP.app/Contents/helpers/pydev/pydevd.py" --multiproc --save-signatures --client 127.0.0.1 --port 64097 --file /Users/user1/gitroot/website1/manage.py runserver 0.0.0.0:8000 --verbosity 2
Connected to pydev debugger (build 141.1245)
pydev debugger: process 63926 is connecting
pydev debugger: process 63954 is connecting
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
June 03, 2015 - 09:08:52
Django version 1.7.7, using settings 'myproject.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
更新: 由于此 post Pycharm 具有使用 Cython 作为解释器的能力。我认为这在一定程度上改善了情况。我也转而使用 Runserverplus,我认为它 运行s 更快。
好吧,调试器很慢,您对此无能为力。除非你绝对需要它,否则不要使用调试器(即你正在解决一个特别难以捉摸的错误)。
我能想到的只有一件事可以加速 PyCharm 的调试器,那就是关闭 "Collect run-time types information for code insight" 设置(位于文件 > 设置 > 构建、执行、部署下> Python调试器)。
对我来说,当我记得我 启用了调试器以收集类型信息时,问题得到了改善。
点击
Ctrl-Shift-A
或在Settings > Build, Execution, Deployment > Python Debugger
下搜索collect run-time types information for code insight
取消选中复选框并点击
apply
看看这是否有帮助
我运行PyCharm Community 5.0.1
我注意到原始 poster 的调试输出不包含有关 cython 的消息。我来到这个 post 是因为我无法弄清楚为什么我的 pycharm 调试这么慢,但后来我意识到在我的调试输出中有一个加速调试器的建议。
"<some-path-to-python>/python" "/Applications/PyCharm.app/Contents/helpers/pydev/setup_cython.py" build_ext --inplace
我希望人们已经尝试过了。我想这个答案是为全世界的非输出读者准备的。
需要对这些进行实验,取自Jetbrain blog:
- delete all breakpoints
- turn off tracing exceptions
- no runtime type insights
但也请考虑禁用 Django 模型检查等以加快速度。
我使用了一个补丁来加速测试用例,比 运行 快 10 倍。 所以,如果你做 TDD,函数没有视图那么重。让你快速解决bug。