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

Aar*_*ers 5 python amazon-web-services

我有 AWS EC2 实例,正在运行一些东西,但 python 分析器在那里坏了

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
Run Code Online (Sandbox Code Playgroud)

我不想重新安装所有 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
Run Code Online (Sandbox Code Playgroud)

有什么帮助吗?重申一下,我已经尝试向 resources.list 文件添加各种行,但没有任何效果,所以请不要只搜索并发布链接,除非您自己成功解决了这个问题,谢谢!

Aar*_*ers 2

我发现缺少的模块pstats.py是一个普通的 python 模块,因此您所要做的就是将其放在 Python 路径上的某个位置。

我不会删除它,希望它能对其他人有所帮助。