pstats module missing in python 2.x

Bug #123755 reported by Matteo Bertini on 2007-07-03
58
This bug affects 11 people
Affects Status Importance Assigned to Milestone
python-defaults (Ubuntu)
Undecided
Matthias Klose
Declined for Jaunty by Matthias Klose

Bug Description

Binary package hint: python

python2.5
Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pstats
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pstats

naufraghi@rosen:~$ python2.4
Python 2.4.4 (#2, Apr 26 2007, 00:02:45)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pstats
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named pstats

http://docs.python.org/lib/profile-instant.html
-----------
When you wish to review the profile, you should use the methods in the pstats module. Typically you would load the statistics data as follows:

import pstats
p = pstats.Stats('fooprof')

Matteo Bertini (naufraghi) wrote :

Not a bug: pstats.py is in python-profiler

but...

python-profiler is perhaps a missing dep of python-all or at least of python-all-dev

Matthias Klose (doko) wrote :

as already mentioned, the pstats module can be found in the python-profiler package in multiverse; the -all packages are meant to be used in build dependencies, not in package dependencies.

Changed in python-defaults:
assignee: nobody → doko
status: New → Invalid
Jon Wright (wright-esrf) wrote :

This seems like a bug to me: pstats is in the python standard library.

Tim D (humbletim) wrote :

I also think this qualifies as a distro bug because the profiling modules (hotshot, profile, pstats, etc.) are only ever described as part of the Python Standard Library. All tutorials I've been trying lately (found through Googling) present these modules as out-of-the-box Python components -- I was surprised to have to install additional packages to get a "real" Python environment.

I guess profiling is an advanced topic and users hitting this roadblock will likely figure it out, but how about at least making the error message specify that it's a missing Ubuntu package (and not a Python easy_install, egg, etc.):

current: <type 'exceptions.ImportError'>: No module named profile; please install the python-profiler package
suggestion: <type 'exceptions.ImportError'>: No module named profile; please install Ubuntu's python-profiler package (for example: sudo apt-get install python-profiler)

Best regards, -Tim / 8.04

Peter McLachlan (spark343) wrote :

Agreed. Still not fixed in Jaunty. pstats is part of the core python distribution, it does not belong in multiverse.

Matthias Klose (doko) wrote :

> it does not belong in multiverse.

wrong. see the license.

bryanvick (bryanvick) wrote :

Not being a part of the standard library caused me some confusion when setting up a isolated python environment with zc.buildout and virtualenv. Because apt-get won't install pstats.py into my virtualenv, I had to copy the pstats.py file into my virtualenv. Not difficult, but certainly not intuitive. Also, inside my setup.py, I can't define a dependency on pstats.py that will automatically be downloaded by zc.buildout because there is no pstats egg in PYPI. So when I release my egg, I have to have another mechanism to alert users that the pstats module is required.

Peter (maubp) wrote :

Bug still present in Karmic

Carl Vondrick (carl-vondrick) wrote :

Still present in Lucid.

Alexander Schliep (schliep) wrote :

@Matthias Klose:

Would you care to specify why the profiler's license violates the Ubuntu 'main' component licence policy
http://www.ubuntu.com/project/about-ubuntu/licensing? Granted the code has none of the standard licenses (it is from 94 after all), but from my reading of http://docs.python.org/library/profile.html#module-profile all points are addressed (source code, modification, distribution of modified copies under same license.).

What reads confusing is the bit of "This permission is explicitly restricted ... exclusively imported into a Python module", but then it is a Python profiler after all and I honestly can't see what this might restrict.

I don't use Ubuntu, but had users stumble over this bug in Ubuntu packaging. If you maintain your stance
on excluding parts of the *Python standard library* then please do rename the Ubuntu Python to something
else; because without the *Python standard library* it ain't Python. All other partial implementation and ports
I am aware of do reflect their incompleteness by altering the name.

PS: Are there any other parts of the *Python standard library* missing?

Matthias Klose (doko) wrote :

see http://bugs.debian.org/293932 for the history
yes, the restriction on the use of the modules prevents the inclusion in main.
no other parts of the standard library are missing, but may be packaged in separate binary packages. The tests are not packaged.

mdshort (mdshort) wrote :

I just ran into this problem. I was installing the repoze profiling tools for my pylons and all the sudden I was missing some module called pstats. If ubuntu is going to break stdlib then at least blab something when the lib is included...

Download full text (6.4 KiB)

Copying a response from the Debian mailing list linked above that includes an email from James Roskind, the original author. The basic problem is that the profiler module restricts copying & altering the code to work done in python or for a python module - as such, it is too restrictive to fit into Debian's (and thus Ubuntu's) standard repos. Unfortunately, the company who owned the copyright has since been bought by Disney & then dissolved, so it isn't likely that anybody with the authority to update the license will be found. Really, the best bet - other than just notifying users that they'll need to find this package elsewhere (such as the multiverse repo) - would be to rewrite the library from scratch. It doesn't seem like that complicated of a task, but at the end of the day, whether it is worth it or not is a different question.

Anyhow, cutting & pasting the post from the Debian list, including Roskind's response:

--- (from http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=130;bug=293932) ---

From: David Ascher <email address hidden>
To: <email address hidden>
Cc: Tim Peters <email address hidden>, <email address hidden>,
 Matthias Klose <email address hidden>, <email address hidden>
Subject: Re: [Python-Dev] license issues with profiler.py and md5.h/md5c.c
Date: Sat, 12 Feb 2005 13:45:54 -0800
On Tue, 8 Feb 2005 15:52:29 -0500, Jeremy Hylton <email address hidden> wrote:
> Maybe some ambitious PSF activitst could contact Roskind and Steve
> Kirsch and see if they know who at Disney to talk to... Or maybe the
> Disney guys who were at PyCon last year could help.

I contacted Jim. His response follows:

---
I'm a strong supporter of Opensource software, but I'm probably not
going to be able to help you very much. I could be much more helpful
with understanding the code or its use ;-).

To summarize what I'll say: I don't own the rights to this stuff. ...
but I don't believe there are any patents that I was ever involved
with that might encumber this work.

I would note that my profiler code is really very rarely used in
commercial products, and it is much more typically used by developers
(I guess a developer toolkit, if sold, would use it). I'm pretty
delighted that the code has found so much use by developers over the
years. As I noted in the intro to the documentation, I had only been
coding in Python for 3 weeks when I wrote it. On the positive side,
it exposed many weaknesses in many developer's code (including our own
at InfoSeek), as well as in core Python code (subtle bugs in the
interpreter) that surely helped everyone. Even though I was a newbie,
It was VERY carefully crafted,, and I'd expect that it would take a
fair amount of effort to reproduce it (and that is is probably why it
has not been changed much... or at least no one told me when they
changed/fixed it ;-) ).

With regard to why I probably can't help much.....

First off, InfoSeek (holder of the copyright) was bought by Disney,
and I don't know what if anything has eventually become of the
tradename. There is a chance that Disney owns the rights... and I
have no idea who to ask there :-/.

Second, I took a look at the Copyright, and it sure seems pretty
...

Read more...

Martin Spacek (mspacek) wrote :

Still a problem in natty.

summary: - pstats module missing in python 2.4 and 2.5
+ pstats module missing in python 2.x
Martin Spacek (mspacek) on 2011-10-03
Changed in python-defaults (Ubuntu):
status: Invalid → Opinion
Alain Kalker (miki4242) wrote :

Another sufferer of this 'bug' here.

Siding with Comment #10, I would strongly suggest renaming the affected Python packages by adding 'dfsg' to the package name, as has been done many times before in similar cases. See also: https://wiki.ubuntu.com/PackagingGuide/Complete and the DFSG.

I would also like to suggest noting the python-profiler package (and any other non-free packages) in the package description, as this is where users are supposed to look to find out what a package is about, and what functionality it does or doesn't offer.

Damian Yerrick (tepples) wrote :

Wasn't the license on this module changed some time ago?
From <http://bugs.python.org/issue12417>:
"I have a patch that has passed Disney legal to resolve the problem."

Matthias Klose (doko) wrote :

now available in all pythonX.Y packages in precise

Changed in python-defaults (Ubuntu):
status: Opinion → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.