调试pycharm中的python代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了调试pycharm中的python代码相关的知识,希望对你有一定的参考价值。
这个问题与this类似。我正在尝试使用以下配置调试pyethapp:
入口点位于app.py.没有被调试时代码运行正常,但是一旦我启动调试器,就抛出以下异常:
Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt
/usr/local/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
% self._get_c_name())
Traceback (most recent call last):
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "app.py", line 27, in <module>
from console_service import Console
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "console_service.py", line 38, in <module>
@inputhook_manager.register('gevent')
AttributeError: 'InputHookManager' object has no attribute 'register'
解决方案建议here(重新安装ipython)没有解决问题(它只在调试时发生;客户端在单独运行时工作)。
编辑:
输出中的命令行:
/usr/bin/python2.7 /home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support --client 127.0.0.1 --port 59087 --file app.py --profile testnet --data-dir testnetState/ run
warning: Debugger speedups using cython not found. Run '"/usr/bin/python2.7" "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/setup_cython.py" build_ext --inplace' to build.
pydev debugger: process 20493 is connecting
Connected to pydev debugger (build 145.260)
Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt
/usr/local/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
% self._get_c_name())
Traceback (most recent call last):
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "app.py", line 27, in <module>
from console_service import Console
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "console_service.py", line 38, in <module>
@inputhook_manager.register('gevent')
AttributeError: 'InputHookManager' object has no attribute 'register'
答案
如果您使用旧版本的IPython(其中确实尚未实现register
方法),则会发生此错误。由于您可能使用OSX,其中包含默认的Python安装,您的环境中可能存在一些冲突的Ipython副本,其常规和调试配置会调用其不同版本?
通过将项目移动到根软件包无法干扰的虚拟环境中,可能会解决此问题。
另一答案
要摆脱cython missing
警告,请运行:
python2 /.......git/liclipse/plugins/org.python.pydev_6.2.0.201711281546/pysrc/setu p_cython.py build_ext --inplace
最后,调试窗口保持清洁那些可怕的警告和混乱。
以上是关于调试pycharm中的python代码的主要内容,如果未能解决你的问题,请参考以下文章
无法调试 PyCharm 2020.1 中的代码 - Python 3.5 EOL 错误