繁体   English   中英

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

[英]How to configure Amazon EC2 instance to support 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路径上的某个位置。

我并不是要删除它,以希望对其他人有所帮助。

Python探查器位于社区支持的Ubuntu“ multiverse”中,因此只需安装Python探查器,只需取消对APT源文件中的multiverse行的注释即可。 如果您尝试像我一样自动执行服务器安装,则这些命令应该有效:

$ sudo sed -i '/natty[^ ]* multiverse/s/^# //' /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install python-profiler

祝好运!

您可以直接下载python-profiler包并运行dpkg

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM