Hey I am newbie in python.I have installed python 2.7.5 correctly.It is working fine but I am having some issues.I have set windows Enviroment variables.
Please be a lot more specific. Do you have any particular environment
variables you suspect, and if so, what have you set them to?
The problem is when I try to save my program in a folder(C:\Users\John\X)it shows that module error
Then you'd better tell us what program you were using to save it with.
I've never seen that error from emacs or Notepad++, but perhaps you're
doing something else.
but when I save it outside this X folder ( C:\Users\John ) It runs successfully.How to fix it?
Perhaps you'd better start at the beginning. Thanks for telling us
you're using python Version 2.7.5, Now perhaps you mean not that this
error occurs during the save, but instead during running of the program.
So let's try again. Don't try to answer just certain parts of the
below, but instead make your own problem description that's at least as
thorough. By the time you're done, you just might solve the problem
yourself, or you'll have learned something new about the problem. But
at least you'll help us help you.
You have saved some program (what is its name?) (why not include it
here, since it probably only needs about 3 lines, including an import of
some form?) in the directory C:\Users\John\X.
You then run it, from a cmd prompt, as follows:
C:\Users\John\X > python myprog.py
and you get the following error.
(You fill this in. It's a group of lines called a traceback, and the
whole thing can be useful. Don't summarize or retype it, use copy/paste).
You then move the file to directory C:\Users\John\betterplace, do a cd
there, and run it again from that directory. Now it works, no import
errors, and runs to completion.
So what else is in that first directory? Are you referencing X
somewhere in your code? Are you referencing __name__ (which is a
reserved term with very specific meaning)?
Have you tried keeping the program in C:\Users\John\X but running with
a different current directory?
C:\Users\John\testdir > python ..\X\myprog.py
If I had to mount my crystal ball, I'd say you've got some form of
recursive import going on (thus __main__), and that some module or
package has the name X. You might also have more than one copy of some
python source file, or a sys.path that's messed up.
Some general advice for the future: Avoid using any uppercase in file
and directory names for source code. Avoid any single-letter names.
Avoid doing recursive imports, and NEVER import the script itself from
some other file.
One more thing. Before replying, please read this since you're using
googlegroups:
http://wiki.python.org/moin/GoogleGroupsPython.