Python not starting

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun May 5 14:55:49 EDT 2013


On Sun, 05 May 2013 06:43:25 -0700, rama29065 wrote:

> I was using python from over an year and half.Suddenly from yesterday
> i'm unable to run it. 

Well, the obvious question is, what did you do yesterday to change your 
system? Did you install any new packages? Run a Windows update? Delete 
some stuff? Something changed. What was it?


> The error is as follows
>
> Traceback (most recent call last):
>   File "C:\Python27\lib\site.py", line 563, in <module>
>     main()
>   File "C:\Python27\lib\site.py", line 546, in main
>     known_paths = addsitepackages(known_paths)
>   File "C:\Python27\lib\site.py", line 324, in addsitepackages
>     if os.path.isdir(sitedir):
>   File "C:\Python27\lib\genericpath.py", line 44, in isdir
>     return stat.S_ISDIR(st.st_mode)
> AttributeError: 'module' object has no attribute 'S_ISDIR'


This is a Python error, so Python is definitely starting. It's starting, 
hitting an error, and then failing with an exception.

Interestingly, the error is in os.path.isdir. The os module should be 
importing the ntpath module. The ntpath module tries to import _isdir 
from the nt module, and if that fails, falls back on genericpath.isdir. 
Which is what fails. So you have two problems:

- why is your nt module missing?

- why does genericpath.isdir fail?


Try running Python from the command line with the -S switch:


python -S


(you might need to use /S on Windows instead, I'm not sure.) Note that 
this is uppercase S, not lowercase. -S will disable the import of site.py 
module, which hopefully will then give you a prompt so you can run this:


import nt
print nt.__file__


which hopefully will show you have created a file called "nt.py" which is 
interfering with the actual nt file needed by Python. Get rid of that, 
and you should be right.



-- 
Steven



More information about the Python-list mailing list