给出’int’对象的python cProfile是不可调用的错误
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了给出’int’对象的python cProfile是不可调用的错误,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2043字,纯文字阅读大概需要3分钟。
内容图文
![给出’int’对象的python cProfile是不可调用的错误](/upload/InfoBanner/zyjiaocheng/730/620a623005a041b89e3aa17461436a83.jpg)
以下脚本运行很棒:
$python myscript.py
当我尝试使用cProfile配置我的代码时:
$python -m cProfile -s time myscript.py
要么
$python -m cProfile myscript.py
我收到以下错误:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 121, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cProfile.py", line 190, in <module>
main()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cProfile.py", line 183, in main
run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cProfile.py", line 36, in run
result = prof.print_stats(sort)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cProfile.py", line 81, in print_stats
pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pstats.py", line 92, in __init__
self.init(arg)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pstats.py", line 106, in init
self.load_stats(arg)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pstats.py", line 130, in load_stats
arg.create_stats()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cProfile.py", line 92, in create_stats
self.snapshot_stats()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cProfile.py", line 106, in snapshot_stats
callersdicts[id(entry.code)] = callers
TypeError: 'int' object is not callable
我的脚本在两种情况下都成功运行,只是在后一种情况下它会阻塞cProfile.我知道它必须是非常小的东西,只是不能指出它.
请帮我解决.谢谢
解决方法:
你有一个名为id的整数变量,它掩盖了内置函数id.这就搞乱了cProfile.
重命名你的id变量,cProfile应该可以正常工作.
内容总结
以上是互联网集市为您收集整理的给出’int’对象的python cProfile是不可调用的错误全部内容,希望文章能够帮你解决给出’int’对象的python cProfile是不可调用的错误所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。