2011-07-29 61 views
4

我有AWS EC2实例与东西运行和蟒蛇分析器坏了有如何配置Amazon 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文件中添加各种行,并且 没有任何工作,所以请不要只搜索和发布链接,除非您自己成功解决了 此问题,谢谢!

回答

1

我发现丢失的模块pstats.py是一个普通的Python模块,所以你所要做的就是把它放在Python路径上的某个地方 。

我不删除这个,希望它能帮助别人。

1

Python探查器位于社区支持的Ubuntu“multiverse”中,因此要安装Python探查器,只需取消注释APT源文件中的多个宇宙线。如果您尝试自动化服务器安装 - 就像我一样 - 那么这些命令应该工作:

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

祝您好运!

0

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