Re: (Issue resolved!) Issue with Python module downloads from Library for a beginner Python coder.

2020-08-02 Thread Sarvesh Poddar via Python-list
 Hi terry,
I am so happy to mention that your suggestion worked! I moved the file from 
Tkinter to Lib and I am suddenly able to import the file. 
Thanks you so much @Bob, @Arjun, @Cameron for your suggestions. I can finally 
move forward. I hope to contribute to this community in future after gaining 
enough experience on the Python subject. Looking forward!
On Monday, 3 August, 2020, 12:51:28 am IST, Terry Reedy  
wrote:  
 
 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 "", line 1, in 
>     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/".  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//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 "", 
> line 1, in     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


-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-02 Thread Sarvesh Poddar via Python-list
 Hello Dennis,
Sorry for my copy-paste error and thanks for highlighting the same. I will make 
sure that from next time I will maintain the line breaks.
I tried opening it in CMD and it did open with the skewed triangle figure 
although I am still not able to use it in my IDLE environment. Unfortunately, I 
am not able to move ahead with my Python classes because of this, as it 
specifically asks to import the module before proceeding. I saved the file in 
tkinter folder now and receive the same problem,
>>> import graphicsTraceback (most recent call last):  File "", line 
>>> 1, in     import graphicsModuleNotFoundError: No module named 
>>> 'graphics'
Location of the file - C:\Program Files (x86)\Lib\tkinter

Didn't work out.
On Monday, 3 August, 2020, 12:47:26 am IST, Dennis Lee Bieber 
 wrote:  
 
 On Sun, 2 Aug 2020 06:36:28 + (UTC), Sarvesh Poddar via Python-list
 declaimed the following:

> Hi,
>I am currently using Python 3.8.5 with IDLE environment that comes 
>pre-installed with the Python application. I am using the book "An 
>Introduction to computer science" by John Zelle as my reference.
>The problem I am facing is "There is a python program named "graphics.py" that 
>is used as reference in the book and I downloaded the python file from 
>internet (link to the file - 
>https://mcsp.wartburg.edu/zelle/python/graphics.py). I have kept this module 
>in (C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and this is 
>were my Python files also lie in C drive. The problem is that I am not able to 
>import graphics.py file and when I try to do that following is the error I 
>receive,
>Traceback (most recent call last):
>  File "", line 1, in     import graphics
>  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
> 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,
>

    In future, you might want to ensure your cut and/or posting
client, maintains line breaks -- many of your pastes seem to "unwrap"
stuff...


>When I write a different line -  (from import graphics *), this is the output:
>from graphics import *Traceback (most recent call last):  File "", 
>line 1, in     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

... such as the above, which appears to have turned something like 7 lines
of output into one long string/paragraph.


    My only suggestion is to drop OUT of IDLE or whatever, and open a
Windows command shell... and try running a script from that shell. I note
that this library makes use of Tkinter -- which is also used by IDLE. The
two uses may be causing complications. Going to a command shell avoids
that.

-=-=-
C:\Users\Wulfraed\Downloads>type testgraphics.py
import graphics

print(dir(graphics))


C:\Users\Wulfraed\Downloads>python testgraphics.py
['BAD_OPTION', 'Circle', 'DEFAULT_CONFIG', 'Entry', 'GraphWin',
'GraphicsError', 'GraphicsObject', 'Image', 'Line', 'OBJ_ALREADY_DRAWN',
'Oval', 'Point', 'Polygon', 'Rectangle', 'Text', 'Transform',
'UNSUPPORTED_METHOD', '_BBox', '__builtins__', '__cached__', '__doc__',
'__file__', '__loader__', '__name__', '__package__', '__spec__',
'__version__', '_root', '_update_lasttime', 'color_rgb', 'os', 'sys',
'test', 'time', 'tk', 'update']

C:\Users\Wulfraed\Downloads>
-=-=-

    Heck... from the command shell, navigate to the directory in which you
saved graphics.py and enter

-=-=-
C:\Users\Wulfraed\Downloads>python graphics.py
-=-=-

    On my system, that pops up a small window with skewed triangle, some
text, and a grey input field.


-- 
    Wulfraed                Dennis Lee Bieber        AF6VN
    wlfr...@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

-- 
https://mail.python.org/mailman/listinfo/python-list  
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-02 Thread Terry Reedy

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 "", line 1, in 
    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/".  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//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 "", line 1, in 
    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


--
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-02 Thread Bob van der Poel
Do you have tkinter installed? The graphics.py module needs it to run.

On Sat, Aug 1, 2020 at 11:36 PM Sarvesh Poddar via Python-list <
python-list@python.org> wrote:

>  Hi,
> I am currently using Python 3.8.5 with IDLE environment that comes
> pre-installed with the Python application. I am using the book "An
> Introduction to computer science" by John Zelle as my reference.
> The problem I am facing is "There is a python program named "graphics.py"
> that is used as reference in the book and I downloaded the python file from
> internet (link to the file -
> https://mcsp.wartburg.edu/zelle/python/graphics.py). I have kept this
> module in (C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and
> this is were my Python files also lie in C drive. The problem is that I am
> not able to import graphics.py file and when I try to do that following is
> the error I receive,
> Traceback (most recent call last):
>   File "", line 1, in import graphics
>   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
>  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,
>
> 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
> "", line 1, in from graphics import *  File
> "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py",
> line 1Python 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
> Please do let me know if I am missing out something very basic.
> Thanks and I look forward.On Saturday, 1 August, 2020, 07:54:19 am
> IST, boB Stepp  wrote:
>
>  On Thu, Jul 30, 2020 at 9:24 AM Sarvesh Poddar via Python-list
>  wrote:
>
> > I re-installed Python in my Windows system as the earlier one was not
> able to import modules...
>
> You do not provide much detail to diagnose what your problem(s)
> is(are).  By the "earlier one" is it the same version as the one you
> re-installed?  Were you able to run IDLE with the "earlier one"?  By
> not being able to import modules do you mean modules from Python's
> standard library?  Or do you mean installing third party libraries
> using pip?
>
> > ...But now I am not able to open IDLE after multiple tries.
>
> Have you looked in your start menu in the list of installed programs
> for Python?  If it is there did you expand it and see if there is an
> entry for IDLE?  How have you been trying (unsuccessfully) to open
> IDLE?
>
>
> --
> boB
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

 Listen to my FREE CD at http://www.mellowood.ca/music/cedars 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: b...@mellowood.ca
WWW:   http://www.mellowood.ca
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-02 Thread Cameron Simpson
Diverting replies to tu...@python.org, a better place for all this.

It looks like the error is in graphics.py, not in your file.
Your line:

from graphics import *

is syntacticly correct. Something has mangled the line breaks in your 
traceback, which here appears as:

When I write a different line -  (from import graphics *), this is the 
output:
from graphics import *Traceback (most recent call last):  File 
"", line 1, in     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

To me it appears that the syntax error in in graphics.py at line 1. I'd 
normally expect such a traceback to look more like this:

File "", line 1, in 
    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

In particular, the "^" would point to the place in the code where Python 
_noticed_ the syntax error. Is it possible that graphics.py contains 
that "Python 3.8.5 " text?

So the traceback I've invented above says that _your_ import failed, but 
that was because of a failure in the file you were trying to import.

BTW, it looks to me like your Python programmes (graphics.py and 
whatever other file you might be making) are inside the Python install.  
Normally you'd keep these elsewhere, for example in a folder such as:

C:\Users\sarvesh\my-programmes

Cheers,
Cameron Simpson 

On 02Aug2020 06:36, Sarvesh Poddar  wrote:
>I am currently using Python 3.8.5 with IDLE environment that comes 
>pre-installed with the Python application. I am using the book "An 
>Introduction to computer science" by John Zelle as my reference.
>The problem I am facing is "There is a python program named "graphics.py" that 
>is used as reference in the book and I downloaded the python file from 
>internet (link to the file - 
>https://mcsp.wartburg.edu/zelle/python/graphics.py). I have kept this module 
>in (C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and this is 
>were my Python files also lie in C drive. The problem is that I am not able to 
>import graphics.py file and when I try to do that following is the error I 
>receive,
>Traceback (most recent call last):
>  File "", line 1, in     import graphics
>  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
> 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,
>
>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 
>"", line 1, in     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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-02 Thread Sarvesh Poddar via Python-list
 Hi,
I am currently using Python 3.8.5 with IDLE environment that comes 
pre-installed with the Python application. I am using the book "An Introduction 
to computer science" by John Zelle as my reference.
The problem I am facing is "There is a python program named "graphics.py" that 
is used as reference in the book and I downloaded the python file from internet 
(link to the file - https://mcsp.wartburg.edu/zelle/python/graphics.py). I have 
kept this module in 
(C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and this is were 
my Python files also lie in C drive. The problem is that I am not able to 
import graphics.py file and when I try to do that following is the error I 
receive,
Traceback (most recent call last):
  File "", line 1, in     import graphics
  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
 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,

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 "", 
line 1, in     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
Please do let me know if I am missing out something very basic.
Thanks and I look forward.On Saturday, 1 August, 2020, 07:54:19 am IST, boB 
Stepp  wrote:  
 
 On Thu, Jul 30, 2020 at 9:24 AM Sarvesh Poddar via Python-list
 wrote:

> I re-installed Python in my Windows system as the earlier one was not able to 
> import modules...

You do not provide much detail to diagnose what your problem(s)
is(are).  By the "earlier one" is it the same version as the one you
re-installed?  Were you able to run IDLE with the "earlier one"?  By
not being able to import modules do you mean modules from Python's
standard library?  Or do you mean installing third party libraries
using pip?

> ...But now I am not able to open IDLE after multiple tries.

Have you looked in your start menu in the list of installed programs
for Python?  If it is there did you expand it and see if there is an
entry for IDLE?  How have you been trying (unsuccessfully) to open
IDLE?


-- 
boB
  
-- 
https://mail.python.org/mailman/listinfo/python-list