Notes on Ubuntu (Linux) computing

Brief notes on installation, setup and other tasks in the Ubuntu world

Install psutil from google repository

with 3 comments

In order to do some profiling of Python scripts (memory profile, in particular) I am installing psutil and memory_profiler. A nice overview of profiling, both time and memory, can be found here.

To start, we install psutil. First, clone the repository using mercurial (make sure to execute the following in sensible place):

hg clone https://code.google.com/p/psutil/

Next, cd into the new directory and install:

cd psutil
sudo python setup.py install

Finally, start Python and try the following commands:

import psutil
print psutil.cpu_times()
print psutil.virtual_memory()

These commands should provide information you would normally obtain using the top command. Check the website for further examples.

Advertisements

Written by Chris S

December 30, 2013 at 9:52 pm

Posted in Python

Tagged with , ,

3 Responses

Subscribe to comments with RSS.

  1. I assume for some reason that you want the latest code, you should be able to install development directly by

    `pip install hg+https://code.google.com/p/psutil/`

    This also works for Git, and other VCS, see http://www.pip-installer.org/en/latest/logic.html#vcs-support

    If latest code isn’t the goal, stable release is, then just `pip install psutil`, the package is already on PyPI.

    livibetter

    December 30, 2013 at 10:30 pm

    • Yes, I was going for the latest code. Your example of using pip for the same task is very nice — thanks!

      Chris S

      December 30, 2013 at 11:20 pm

  2. […] In order to do memory profiling of Python scripts I am installing memory_profile. It is recommended that psutil be installed– we covered this in a previous post. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: