How to configure an Amazon EC2 instance to support python profiler?

I have AWS EC2 instances with running files and the python profiler is broken there.

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 

I would prefer not to reinstall all of Python, because there are things in the systems. I just want to add / fix the profiler. I found advice on how to do this, which doesnโ€™t work, for example http://www.cherrypy.org/wiki/ProfilingOnDebian . No matter what I try, I get

 $ 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 

Any help? To repeat, I tried to add various lines to the sources.list file and nothing worked, so please do not just search and send the link if you did not solve this problem successfully, thanks!

+4
source share
3 answers

I realized that the missing pstats.py module is a simple python module, so all you have to do is put this somewhere in the Python path.

I do not delete it in the hope that it will help someone else.

+1
source

The Python profiler lives in the community-supported โ€œmulti-userโ€ Ubuntu, so to install the Python profiler you just need to uncomment the multiverse lines in the APT source file. If you are trying to automate the server installation - just like me, then these commands should work:

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

Good luck

+1
source

You can directly download the python-profiler package and run dpkg

0
source

All Articles