Python not starting

R

rama29065

I was using python from over an year and half.Suddenly from yesterday i'm unable to run 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'
 
R

Roy Smith

I was using python from over an year and half.Suddenly from yesterday i'm
unable to run 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'

Just a wild guess, but did you happen to create a module of your own
named "stat", which is getting imported instead of the one from the
library?

Try doing:

and see what it says.
 
D

DRJ Reddy

(e-mail address removed) wrote:
















Just a wild guess, but did you happen to create a module of your own

named "stat", which is getting imported instead of the one from the

library?



Try doing:






and see what it says.

Even from command prompt i can't start python.The error is coming up.Python in Windows7 box.
 
R

Roy Smith

Even from command prompt i can't start python.The error is coming up.Python
in Windows7 box.

I don't know Windows, but my guess is still that it's finding some other
file called stat.py before it's finding the system library one. Try
doing a file system search for all files named "stat.py" and see what
you find. On unix, I would do "find / -name stat.py". I assume there's
something similar on Windows.

The other thing I would try is tracing the python process as it starts
up. On unix, I would do something like "strace -e trace=file python"
and see if it's finding a stat.py in some unexpected place. Again, I
can only assume there's something similar on Windows.

Oh, and please don't post with Google Groups. It double-spaces
everything and makes your message really difficult to read.
 
M

Mark Lawrence

Even from command prompt i can't start python.The error is coming up.Python in Windows7 box.

Place the call to print stat.__file__ in the file genericpath.py
immediately before the line that gives the attribute error.

Would you also be kind enough to read and use the guidance given in the
link in my signature. My eyesight is bad enough without parsing double
spaced stuff courtesy of google groups, thanks.
 
D

DRJ Reddy

I don't know Windows, but my guess is still that it's finding some other

file called stat.py before it's finding the system library one. Try

doing a file system search for all files named "stat.py" and see what

you find. On unix, I would do "find / -name stat.py". I assume there's

something similar on Windows.



The other thing I would try is tracing the python process as it starts

up. On unix, I would do something like "strace -e trace=file python"

and see if it's finding a stat.py in some unexpected place. Again, I

can only assume there's something similar on Windows.



Oh, and please don't post with Google Groups. It double-spaces

everything and makes your message really difficult to read.

I found a stat.py in python27/idlelib i haven't created one.
 
D

DRJ Reddy

Place the call to print stat.__file__ in the file genericpath.py

immediately before the line that gives the attribute error.



Would you also be kind enough to read and use the guidance given in the

link in my signature. My eyesight is bad enough without parsing double

spaced stuff courtesy of google groups, thanks.



--

If you're using GoogleCrap� please read this

http://wiki.python.org/moin/GoogleGroupsPython.



Mark Lawrence

Sorry for double spaced stuff,how can i get rid of it.
 
C

Chris Angelico

I don't know Windows, but my guess is still that it's finding some other
file called stat.py before it's finding the system library one. Try
doing a file system search for all files named "stat.py" and see what
you find. On unix, I would do "find / -name stat.py". I assume there's
something similar on Windows.

Or alternatively, disable site.py by invoking python -S, and then
manually import stat and see what its file is.

ChrisA
 
D

DRJ Reddy

Or alternatively, disable site.py by invoking python -S, and then

manually import stat and see what its file is.



ChrisA

Thanks all of you,i have done it,by disabling,but what is the permanent solution.How can i start python idle
 
C

Chris Angelico

Thanks all of you,i have done it,by disabling,but what is the permanent solution.How can i start python idle

Here's the steps:

1) Start Python with the -S option. You have apparently figured this
part out. This should give you a working interactive Python.

2) Type:
import stat
stat.__file__

3) See what the file is that was named there. If you created it, you
now know the problem.

4) Read Mark Lawrence's signature.

This post adds nothing to what has already been said; it's just
coalescing the previously-given advice into exact steps.

ChrisA
 
D

DRJ Reddy

Chris i have seen stat.__file__. It gives me 'C:\\Python27\\lib\\stat.pyc'. What should i do now.
 
R

Roy Smith

If you're using GoogleCrap� please read this

http://wiki.python.org/moin/GoogleGroupsPython.



Mark Lawrence

Sorry for double spaced stuff,how can i get rid of it.[/QUOTE]

I don't mean to be disrespectful, but did you actually read the page you
were asked to read? It says, about halfway down the page, "You should
remove the excess quoted blank lines before posting. There are several
way to do this.", and then goes on to describe three different ways.
 
D

DRJ Reddy

I did read and understood that while replying if > is there we will get a blank line unnecessarily.
 
S

Steven D'Aprano

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.
 
A

Andrew Berg

(you might need to use /S on Windows instead, I'm not sure.)
That is only a convention among Microsoft's CLI utilities. Very few others follow it (even for programs written specifically for Windows),
and it is certainly not a necessity on Windows.
 
C

Chris Angelico

I did read and understood that while replying if > is there we will get a blank line unnecessarily.

If you read that page, you'll know that it does NOT advocate the total
elimination of quoted text, which is what you've now done. Please
don't. Your posts now lack any form of context.

ChrisA
 
D

drjreddy7

import nt

print nt.__file__
I have done above ones as you stated.
I'm getting an error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'
 
D

drjreddy7

I did read and understood that while replying if > is there we will get a blank line unnecessarily.
If you read that page, you'll know that it does NOT advocate the total
elimination of quoted text, which is what you've now done. Please
don't. Your posts now lack any form of context.
ChrisA

Sorry ChrisA,not only him for all, for the mess i have created.It was the first time for me on google groups.
I am very happy to inform all of you that the problem is solved. The problem was due to the prescence of duplicates for genericpath.pyc and stat.pyc.I have deleted them and new ones were generated as i started python.
Thanking all of you for assisting me in solving the issue.
 
C

Chris Angelico

Sorry ChrisA,not only him for all, for the mess i have created.It was the first time for me on google groups.
I am very happy to inform all of you that the problem is solved. The problem was due to the prescence of duplicates for genericpath.pyc and stat.pyc.I have deleted them and new ones were generated as i started python.
Thanking all of you for assisting me in solving the issue.

Excellent! Glad it's sorted.

The .pyc problem is, if I understand correctly, more permanently
solved in newer versions of Python. So this won't ever be an issue
again :)

ChrisA
 
S

Steven D'Aprano

I am very happy to inform all of
you that the problem is solved. The problem was due to the prescence of
duplicates for genericpath.pyc and stat.pyc.I have deleted them and new
ones were generated as i started python. Thanking all of you for
assisting me in solving the issue.


Well, I'm glad it's sorted, but the solution raises as many questions as
it answers.

How did you get duplicate genericpath.pyc and stat.pyc files?

If they were duplicates, why didn't they have the right code in them?

It's probably not worth spending any more time investigating, but it is
still rather mysterious.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top