1

According to the Python documentation, the "profile" module is part of the standard library.

But I can't find it.

On my home machine, I was able to add it using apt-get install. (ie. it's split out into a separate ubuntu package.)

On my work machine, (also ubuntu) I'm running in a virtualenv, so apt-get install isn't relevant. I can install python modules from pypi using easy-install, but I can't see anything on pypi which corresponds to the profiling module. (Presumably because it's meant to be part of the standard python install.)

So how can I install it in this environment?

2 Answers 2

1

Whether you're using a virtualenv or not, you should still be able to import the profile module. If you're simply not seeing it in the lib/ directory, don't let that bother you.

(t)imac:~ jeff$ virtualenv t
New python executable in t/bin/python
Installing setuptools............done.
(t)imac:~ jeff$ t/bin/python -m 'profile'
Usage: profile.py [-o output_file_path] [-s sort] scriptfile [arg] ...

(t)imac:~ jeff$ 

But when looking in the virtualenv's lib directory, there's no corresponding module. See below.

(t)imac:t jeff$ ls lib/python2.6/prof*
ls: lib/python2.6/prof*: No such file or directory
(t)imac:t jeff$ 
3
  • I'm afraid that's not it. "import profile" is, actually, failing.
    – interstar
    Mar 19, 2010 at 18:39
  • Standard ImportError? If you had to install it separately, my guess is that that additional Ubuntu directory isn't added to the virtualenv path by default when it's set up. Add the location of the python-profiler files to your python path manually (or to your local site.py, or to your bin/activate, or...).
    – McJeff
    Mar 19, 2010 at 18:59
  • So... yeah, okay, just tested it. That extra package adds it to your standard Python path, but since virtualenv references that same path, it has to exist globally. Install the .deb on your work machine and it should work within the virtualenv as well. Might have to recreate the virtualenv, but I don't believe so. Shouldn't have to add anything to your python path manually once you install that package.
    – McJeff
    Mar 19, 2010 at 19:05
1

Ubuntu's default installation of Python is different from the standard Python download, both for size and licensing reasons. To get the profile module back, you need to enable the multiverse repositories (where unsupported and questionable software goes), and install the python-profiler package.

This has been filed as a bug, for reference.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .