Python won't run

Ned Deily nad at acm.org
Mon Mar 2 00:51:39 EST 2009


In article 
<e983abbe-3a3b-41db-95ae-a8336dd4c26c at y33g2000prg.googlegroups.com>,
 dkiekow at gmail.com wrote:
> On Feb 23, 5:01 pm, Ned Deily <n... at acm.org> wrote:
> > On Feb 23, 2009, at 14:03 , kevin hayes wrote:
> > > Ned, system log didn't do anything when I tried to open IDLE. However, 
> > > this
> > > is what's in the console.log. does this tell you anything?
> >
> > > Unhandled server exception!
> > > Thread: SockThread
> > > Client Address:  ('127.0.0.1', 8833)
> > > Request:  <socket._socketobject object at 0x1087bc8>
> > > Traceback (most recent call last):
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketSer
> > > v er.
> > > py", line 281, in _handle_request_noblock
> > >     self.process_request(request, client_address)
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketSer
> > > v er.
> > > py", line 307, in process_request
> > >     self.finish_request(request, client_address)
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketSer
> > > v er.
> > > py", line 320, in finish_request
> > >     self.RequestHandlerClass(request, client_address, self)
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib/r
> > > p c.p
> > > y", line 503, in __init__
> > >     SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr)
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketSer
> > > v er.
> > > py", line 615, in __init__
> > >     self.handle()
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib/r
> > > u n.p
> > > y", line 256, in handle
> > >     import IOBinding
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib/I
> > > O Bin
> > > ding.py", line 12, in <module>
> > >     import tempfile
> > >   File
> > > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/tempfile.
> > > p y",
> > >  line 34, in <module>
> > >     from random import Random as _Random
> > >   File "random.py", line 3, in <module>
> > >     import rand      # handy random-number functions
> > > ImportError: No module named rand
> >
> > > *** Unrecoverable, server exiting!
> >
> > [...]
> >
> > It looks like you have a file named random.py in your Documents
> > directory.  IDLE.app adds ~/Documents to the front of sys.path, python's
> > search path for modules.   Your random.py is being found before the
> > standard library module, random, causing the idle server process to
> > abort.  Rename your random.py* and all should be well for both 2.5 and
> > 2.6.
> I just downloaded the os x installer (2.5) and followed the
> instructions in the wiki to install IDLE. When I double click the icon
> it bounces, but nothing happens. From the command line python -m
> idlelib.idle -n brings up a python terminal window. I tried searching
> for random.py and did not find it. System I'm using is 10.5.6 on a
> MacPro.

It's clear from the traceback above that the standard library random.py 
file is not being imported.  That file is here:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/random.py

There is nothing like "import rand # handy random-number functions" in 
it.  And the path reported is "random.py", not 
"/Library/Frameworks.../random.py".  IDLE.app changes its working 
directory to the Documents directory in your home directory so that path 
is what one would expect for a file from there.

The most likely culprit is in your ~/Documents folder.  That would 
explain why all versions of IDLE are being affected.

A Google seach for that string turns up this:
<http://www.strout.net/python/warmer.py>
Does that ring any bells for you?

How about a Spotlight search for "handy random-number functions"?  

Something else to check is environment variable settings.  What does 
this produce in a terminal shell?:
   env | grep PYTHON

And try temporarily disabling the IDLE preferences files:
   mv ~/.idlerc ~/.idlerc-disabled

If you are seeing the same behavior with multiple versions of IDLE, make 
sure the Console output for each is similar to that above.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list