如何配置Amazon EC2实例以支持python profiler?

我有AWS EC2实例运行的东西,
python profiler在那里打破

Traceback (most recent call last):
  File "test.py", line 6, in <module>
  cProfile.run("test()")
  File "/usr/lib/python2.6/cProfile.py", line 36, in run
    result = prof.print_stats(sort)
  File "/usr/lib/python2.6/cProfile.py", line 80, in print_stats
    import pstats
ImportError: No module named pstats

我宁愿不重新安装所有的Python,因为系统上运行着东西.
我只是想添加/修复探查器.我已经找到了关于如何做到这一点的建议,例如http://www.cherrypy.org/wiki/ProfilingOnDebian.无论我尝试什么,我得到

$sudo apt-get install python-profiler
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python-profiler is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package python-profiler has no installation candidate

有帮助吗?重申一下,我尝试在sources.list文件中添加各种行
什么都没有用,所以请不要只搜索并发布链接,除非你已经解决了
这个问题成功了,谢谢!

最佳答案 我发现丢失的模块
pstats.py是一个普通的python模块,所以你需要做的就是放置

它在Python路径上的某个地方.

我不是删除它,希望它能帮助别人.

点赞