Issue with Python module downloads from Library for a beginner Python coder.

Terry Reedy tjreedy at udel.edu
Sun Aug 2 14:44:15 EDT 2020


On 8/2/2020 2:36 AM, Sarvesh Poddar via Python-list wrote:

[I downloaded]
https://mcsp.wartburg.edu/zelle/python/graphics.py)

I have unmangled the traceback and added explanations.

> Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in <module>
>     import graphics

You typed this in IDLE Shell in response to the >>> prompt.

>   File "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line 1

This says that you put the file in the same directory as python.exe.  It 
should better be in
".../Lib/site-packages" or in a directory in "/Users/<you>".  None the 
less, the import worked.

>     Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
>            ^
> SyntaxError: invalid syntax

This says that the first line of graphics.py begins with "Python 
3.8.5..."  This is the startup message printed by python.exe when run in 
interactive mode, and by IDLE's interactive Shell.  It is text, not 
python code.  It is not the first line of the file at that link (I 
checked).

Look at the file on your disk and check its first line.  You may have to 
put '%appdata%' in the directory box if the /User/<you>/appdata 
directory is hidden on your machine.

>   I have installed, uninstalled and then re-installed Python 3.8.5 multiple times but the problem remains.  

> I did a thorough internet search and most of them suggested using sys path and following is the result,

This suggestion is for when the import fails because the module is not 
found.  In your case, it was found and the import process started.

> import sys>>> sys.path['', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\idlelib', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages']

> When I write a different line -  (from import graphics *), this is the output:
> from graphics import *Traceback (most recent call last):  File "<pyshell#3>", line 1, in <module>    from graphics import *  File "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line 1    Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32           ^SyntaxError: invalid syntax

Same bad first line, same error.


-- 
Terry Jan Reedy




More information about the Python-list mailing list