[Tutor] Re: import pwd?
Timothy M. Brauch
tbrauch@mindless.com
Thu, 11 Jul 2002 13:49:35 -0400
>>On Wed, Jul 10, 2002 at 05:18:18PM -0400, Timothy M. Brauch wrote:
>>| I have a problem. The program runs on a windows computer and generates
a
>>| log of anyone who logins. I have a script that uses getpass,
specifically,
>>| getpass.getuser(). However, since I (re)installed Python 2.2 and
VPython, I
>>| receive the following error:
>>|
>>| Traceback (most recent call last):
>>| File "<pyshell#1>", line 1, in ?
>>| import logger
>>| File "c:\python22\programs\logger.pyw", line 35, in ?
>>| user = getpass.getuser()
>>| File "C:\PYTHON22\lib\getpass.py", line 101, in getuser
>>| import pwd
>>| ImportError: No module named pwd
>>|
>>| So, where is pwd?
>>
>>in POSIX ...
>>
>>Microsoft operating systems originally didn't have the concept of
>>"multi-user". Thus there was no 'pwd' module and no passwords. More
>>recent incarnations have a semblance of multi-user, but are still
>>almost wholly incompatible with POSIX systems.
>>
>>$ python2.2
>>>>> import pwd
>>>>> pwd.__file__
>>'/usr/lib/python2.2/lib-dynload/pwd.so'
>>>>>
>>
>>You don't have 'pwd.so' on windows, and it wouldn't do you any good if
>>I sent it to you.
>>
>>-D
Yeah, I checked the docs and it said pwd was only available in *nix. But
that just brings up two more questions... Why can I import getpass if it
doesn't work on Windows? Okay, supposedly getpass.getpass() should work,
and it does, but with warning messages.
And, question 2, I swear I am not making this up or dreaming or anything,
but this program used to work for me, so why did it stop? It worked when I
wrote it (I think I wrote this one on my windows 'puter, not on one of my
Linux boxes). Then, I reformatted my 'puter because the Windows bloat was
getting to be too much. When I installed Python 2.2 (#28, Dec 21 2001,
12:21:22), and VPython, it quit working. I put the program on a couple
different Win98 and WinME computers and it worked for them. Unfortunately,
it is summer break and I cannot get to the other computers I installed it
on.
The only thing I can think of is that I had a different version of Python
installed previously (but I am almost positive it was a 2.2 flavor) and
somehow it worked. I could post the code and the output files, but I don't
think that would really be much help.
It's not all that important. However, I thought it would have been nice to
keep a log of who was using my windows 'puters.
- Tim