The Famous Error Message: "ImportError: No module named python_script"
I am studying Python language. I have Python 2.5 installed in my PC
which is running on Windows XP. I placed the the script called
"python_script" in C:\Python25 directory where all the other Python
files are.
When I tried to import the script called "python_script", it kept
printing the famous error message: "ImportError: No module named
python_script".
I took the file out of "C:\Python25" directory, placed it in
'C:\PythonTests'. The error message kept coming.
The "import" commnand will not work at all.
>>> import python_script
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named python_script
>>> import sys
>>> sys.path
['', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs',
'C:\\Python25\
\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk',
'C:\\Python25
', 'C:\\Python25\\lib\\site-packages']
>>> sys.path
['', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs',
'C:\\Python25\
\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk',
'C:\\Python25
', 'C:\\Python25\\lib\\site-packages']
>>> sys.path.append('C:\PythonTests')
>>> sys.path
['', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs',
'C:\\Python25\
\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk',
'C:\\Python25
', 'C:\\Python25\\lib\\site-packages', 'C:\\PythonTests']
I uninstall Python2.5, installed Python2.4: the result is the same. The
result is the same with older versions of Python also.
Does anybody know a remedy for this???
--
http://mail.python.org/mailman/listinfo/python-list
Re: The Famous Error Message: "ImportError: No module named python_script"
Thank you both for responding. Yes of course the file has the ".py" extension and yes I went through the tutorial. Gabriel Genellina wrote: > At Wednesday 13/12/2006 22:16, rich murphy wrote: > > >I am studying Python language. I have Python 2.5 installed in my PC > >which is running on Windows XP. I placed the the script called > >"python_script" in C:\Python25 directory where all the other Python > >files are. > > Verify the file name, should be "python_script.py" > > You may want to un-select "Hide extensions for known file types" in > Windows Explorer options. > > > -- > Gabriel Genellina > Softlab SRL > > __ > Correo Yahoo! > Espacio para todos tus mensajes, antivirus y antispam ¡gratis! > ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar -- http://mail.python.org/mailman/listinfo/python-list
Re: The Famous Error Message: "ImportError: No module named python_script"
Ben Finney wrote: > "rich murphy" <[EMAIL PROTECTED]> writes: > > > I am studying Python language. > > Welcome! Allow me to direct you to the Python tutorial: > > http://docs.python.org/tut/> > > Please take the time to work through all the exercises in that > document, understanding each one before moving on. > > I recommend this because: > > > I placed the the script called "python_script" in C:\Python25 > > directory where all the other Python files are. > > you would not make this mistake if you had already worked through the > tutorial. The tutorial says: "For instance, use your favorite text editor to create a file called fibo.py in the current directory with the following contents:" So, I assumed "the current directory" is C:\Python25 which did not work. Then I placed the fibo.py file in C: director. That did not work either. What directory does it mean then? > > Enjoy! > > -- > \ "On the other hand, you have different fingers." -- Steven | > `\Wright | > _o__) | > Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: The Famous Error Message: "ImportError: No module named python_script"
Thanks to everyone who responded with valuable suggestions. I appreciate them all. I found the exact reason why "import" command fails. At the beginning I created my script file with MS Notepad. After studying all the advice, I realized that I did not try other text editors just becuase the tutorial says: "use your favorite text editor to create a file called fibo.py in the current directory with the following contents:" Then I created another file with the same stuff in it using WordPad. The behaviour of the "import" command improved a lot but still not good. Then I used MS-DOS' text editor to create the same file. Immediately the "import" command worked as it was supposed to. Almost. "fibo.fib2(100)" command stil does not work. This is fine: >>> fibo.fib(1000) 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 This not fine: >>> fibo.fib2(100) [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] When I enter "fibo.fib2(100)", I get the following: >>> fibo.fib2(100) Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\fibo.py", line 11, in fib2 while b < n: UnboundLocalError: local variable 'b' referenced before assignment This is fine: >>> fibo.__name__ 'fibo' >>> fib=fibo.fib >>> fib(500) 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Both Python2.4 and 2.5 are behaving the same. I will also try to create the file with Vi editor. -- http://mail.python.org/mailman/listinfo/python-list
Could anyone point me to a good site for pearl compiler download
Could anyone point me to a good site for pearl compiler download. -- http://mail.python.org/mailman/listinfo/python-list
