Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"Edit with IDLE" doesn't work any more ?

3,712 views
Skip to first unread message

Yip, Kin

unread,
Apr 28, 2017, 8:07:55 AM4/28/17
to
Hi,

I'm relatively new with Python3 in Windows 7. I'm using now Python 3.6.1.

Suddenly right-clicking on a .py file and choose "Edit with IDLE" just doesn't work.

I've tried to do :

"c:\program files\python36\pythonw.exe" -m idlelib mypythoncodes.py


the IDLE editor just doesn't come up. But if I start the IDLE Shell and then "Open File", the editor is there and
works normally.

I've tried to uninstall "python launcher" and then repair or modify "python3.6 " in Control Panel/Program and Features. Nothing works ...

Any help ? I show you my Windows registry at the bottom of this email.

Kin

PS: My registry :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shell]

[HKEY_CLASSES_ROOT\Python.File\shell\editwithidle]
"MUIVerb"="&Edit with IDLE"
"Subcommands"=""

[HKEY_CLASSES_ROOT\Python.File\shell\editwithidle\shell]

[HKEY_CLASSES_ROOT\Python.File\shell\editwithidle\shell\edit36]
"MUIVerb"="Edit with IDLE 3.6 (64-bit)"

[HKEY_CLASSES_ROOT\Python.File\shell\editwithidle\shell\edit36\command]
@="\"C:\\Program Files\\Python36\\pythonw.exe\" -m idlelib \"%L\" %*"

[HKEY_CLASSES_ROOT\Python.File\shell\open]

[HKEY_CLASSES_ROOT\Python.File\shell\open\command]
@="\"C:\\WINDOWS\\py.exe\" \"%L\" %*"

[HKEY_CLASSES_ROOT\Python.File\shell\Run]

[HKEY_CLASSES_ROOT\Python.File\shell\Run\command]
@="\"C:\\Windows\\py.exe\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.File\shell\runas]

[HKEY_CLASSES_ROOT\Python.File\shell\runas\command]
@="\"C:\\Windows\\py.exe\" \"%1\" %*"

eryk sun

unread,
Apr 28, 2017, 8:27:40 AM4/28/17
to
On Fri, Apr 28, 2017 at 12:04 PM, Yip, Kin <kin...@bnl.gov> wrote:
>
> I've tried to do :
>
> "c:\program files\python36\pythonw.exe" -m idlelib mypythoncodes.py

Change this to use "python.exe" and run it from a command prompt. This
way you can see the traceback if an exception is raised.

Yip, Kin

unread,
Apr 28, 2017, 8:33:06 AM4/28/17
to
Hi Eryk,

If I do:

"c:\Program Files\Python36\python.exe" -m idlelib beersong.py

I see the following :

=======================
Traceback (most recent call last):
File "c:\Program Files\Python36\lib\idlelib\pyshell.py", line 4, in <module>
from tkinter import *
File "C:\Users\kinyip\Desktop\Python Codes\tkinter.py", line 1, in <module>
from turtle import *
File "c:\Program Files\Python36\lib\turtle.py", line 116, in <module>
from tkinter import simpledialog
ImportError: cannot import name 'simpledialog'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Program Files\Python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\Program Files\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Program Files\Python36\lib\idlelib\__main__.py", line 6, in <module>
import idlelib.pyshell
File "c:\Program Files\Python36\lib\idlelib\pyshell.py", line 7, in <module>
"Your Python may not be configured for Tk. **", file=sys.__stderr__)
NameError: name 'sys' is not defined
========================================================================================


Any suggestion ?

Kin

Yip, Kin

unread,
Apr 28, 2017, 8:48:22 AM4/28/17
to
Hi,

I've finally known why .... By chance, I went to the installation directory : C:\Program Files\Python36\Lib\tkinter

to check on files. I did "EDIT with IDLE" on any files there. It all works ! Then, I went back to my directory
where I put all my personal .py codes. It didn't work there. Finally, I've guessed and realized/tested that
"EDIT with IDLE" doesn't work in my python directory because I have just recently made a file called :

tkinter.py


Somehow, this stops "EDIT with IDLE" from working if I try to "EDIT with IDLE" on any files in that directory/folder.

After I rename it to mytkinter.py , things work normally now !

Weird ! Don't know exactly why ...?!

Sorry to bother you guys ...

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

Peter Otten

unread,
Apr 28, 2017, 8:48:27 AM4/28/17
to
Yip, Kin wrote:

> I'm relatively new with Python3 in Windows 7. I'm using now Python 3.6.1.
>
> Suddenly right-clicking on a .py file and choose "Edit with IDLE" just
> doesn't work.
>
> I've tried to do :
>
> "c:\program files\python36\pythonw.exe" -m idlelib mypythoncodes.py
>
>
> the IDLE editor just doesn't come up. But if I start the IDLE Shell and
> then "Open File", the editor is there and works normally.

IDLE shares its import mechanism with every other Python script.

This results in the nasty quirk that if you have other .py files in the same
directory as mypythoncodes.py, and one of these files has the same name as
one of the modules in Python's standard library IDLE will try to run with
your module rather than the one it actually needs. Common candidates are
code.py or string.py, but there are many more.

Once you rename or delete those files IDLE should start working again.

PS: Judging from the traceback in your answer to eryk sun in your case the
offending module may be called tkinter.py



eryk sun

unread,
Apr 28, 2017, 9:02:13 AM4/28/17
to
On Fri, Apr 28, 2017 at 12:32 PM, Yip, Kin <kin...@bnl.gov> wrote:
> Traceback (most recent call last):
> File "c:\Program Files\Python36\lib\idlelib\pyshell.py", line 4, in <module>
> from tkinter import *
> File "C:\Users\kinyip\Desktop\Python Codes\tkinter.py", line 1, in <module>
> from turtle import *
> File "c:\Program Files\Python36\lib\turtle.py", line 116, in <module>
> from tkinter import simpledialog
> ImportError: cannot import name 'simpledialog'

The traceback tells you what you need to know. See how importing
tkinter used your "Python Codes\tkinter.py".

The first part of this problem is that "Edit with IDLE" is executed as
`pythonw.exe -m idlelib "%L" %*`. The -m command-line option adds the
working directory (not the script directory) to the head of sys.path.
The second part is that Explorer starts the process with the working
directory set to the parent directory of the "%L" target file. The 3rd
part is that you have a file in that directory named tkinter.py.
Overall this is a bad experience for beginners, and I know Terry Reedy
is working to improve this.

Peter Otten

unread,
Apr 28, 2017, 9:23:43 AM4/28/17
to
Stefan Ram wrote:

> Peter Otten <__pet...@web.de> writes:
>>one of the modules in Python's standard library IDLE will try to run with
>>your module rather than the one it actually needs. Common candidates are
>>code.py or string.py, but there are many more.
>
> I know this from Java:
>
> When you write a program
>
> ... main( final String[] args ) ...
>
> and then create a file »String.class« in the program's
> directory, the program usually will not work anymore.
>
> However, in Java one can use an absolute path as in,
>
> ... main( final java.lang.String[] args ) ...
>
> , in which case the program will still work in the
> presence of such a »String.class« file.
>
> I wonder whether Python also might have such a kind
> of robust "absolute addressing" of a module.

While I would welcome such a "reverse netloc" scheme or at least a "std"
toplevel package that guarantees imports from the standard library I fear
the pain is not yet big enough ;)


Yip, Kin

unread,
Apr 28, 2017, 9:26:01 AM4/28/17
to
Hi Erky and Peter,

Thanks for the explanations. Next time, I'd try to treat the "traceback" more seriously :-)
I've learnt the difference between python.exe and python.exe and to be more carefully with my code names :-(

Kin

-----Original Message-----
From: eryk sun [mailto:ery...@gmail.com]
Sent: Friday, April 28, 2017 9:01 AM
To: pytho...@python.org
Cc: Yip, Kin <kin...@bnl.gov>
Subject: Re: "Edit with IDLE" doesn't work any more ?

Terry Reedy

unread,
Apr 28, 2017, 3:20:19 PM4/28/17
to
On 4/28/2017 9:01 AM, eryk sun wrote:
> On Fri, Apr 28, 2017 at 12:32 PM, Yip, Kin <kin...@bnl.gov> wrote:
>> Traceback (most recent call last):
>> File "c:\Program Files\Python36\lib\idlelib\pyshell.py", line 4, in <module>
>> from tkinter import *
>> File "C:\Users\kinyip\Desktop\Python Codes\tkinter.py", line 1, in <module>
>> from turtle import *
>> File "c:\Program Files\Python36\lib\turtle.py", line 116, in <module>
>> from tkinter import simpledialog
>> ImportError: cannot import name 'simpledialog'
>
> The traceback tells you what you need to know. See how importing
> tkinter used your "Python Codes\tkinter.py".
>
> The first part of this problem is that "Edit with IDLE" is executed as
> `pythonw.exe -m idlelib "%L" %*`. The -m command-line option adds the
> working directory (not the script directory) to the head of sys.path.
> The second part is that Explorer starts the process with the working
> directory set to the parent directory of the "%L" target file. The 3rd
> part is that you have a file in that directory named tkinter.py.
> Overall this is a bad experience for beginners, and I know Terry Reedy
> is working to improve this.

There is an issue to fix this.
https://bugs.python.org/issue26143
I added a note mentioning this report.

--
Terry Jan Reedy

jonathan...@gmail.com

unread,
Jul 15, 2017, 12:40:50 PM7/15/17
to
Am Freitag, 28. April 2017 14:48:22 UTC+2 schrieb Yip, Kin:
> Hi,
>
> I've finally known why .... By chance, I went to the installation directory : C:\Program Files\Python36\Lib\tkinter
>
> to check on files. I did "EDIT with IDLE" on any files there. It all works ! Then, I went back to my directory
> where I put all my personal .py codes. It didn't work there. Finally, I've guessed and realized/tested that
> "EDIT with IDLE" doesn't work in my python directory because I have just recently made a file called :
>
> tkinter.py
>
>
> Somehow, this stops "EDIT with IDLE" from working if I try to "EDIT with IDLE" on any files in that directory/folder.
>
> After I rename it to mytkinter.py , things work normally now !
>
> Weird ! Don't know exactly why ...?!
>
> Sorry to bother you guys ...
>
> Kin

you da real MVP!

Rick Johnson

unread,
Jul 16, 2017, 1:12:50 AM7/16/17
to
The pain will only get more intense with time. This is an issue that Python3 should have solved when it broke so much backwards compatibility. Better to break it all at once; than again, and again, and again.

md.shoaib...@gmail.com

unread,
Oct 18, 2018, 10:01:27 AM10/18/18
to
Hello Brother I got the promblem.
I got too frustrated. But now i have solution for it.
Just download "api-ms-win-crt-utility-l1-1-0.dll".
For this worked.
And if this doesnt work download these dll too:-
api-ms-win-crt-conio-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-process-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll

This is it. If the problem continues, then i don't know what to do.
I this will Help.
0 new messages