cpython icon indicating copy to clipboard operation
cpython copied to clipboard

3.10.8 IDLE startup failure: No module named 'test'

Open cursorhigh opened this issue 2 years ago • 4 comments

Bug report

I tried everything possible trying it in different pc , using VMware , used it in 10, and 11 , too and still boom idle is not opening , earlier I thought the problem is in my pc but t tried everything and hence its this program problem and also I tried 3.11 and 3.9 , it works perfectly fine

Your environment

i tried it in almost every env with different pc , and hence problem might be in the software i.e. python idle

EDIT by Terry J. Reedy: This is an IDLE regression in 3.10.8. My fault. See https://github.com/python/cpython/issues/98324#issuecomment-1279990057 below for the fixes.

cursorhigh avatar Oct 16 '22 06:10 cursorhigh

python idle not working/opening

Please describe what you did and what happened. Please be precise, it's not enough to say you tried "everything" and "still boom idle is not opening".

What did you do? Double-click a file, type a command at the command prompt, use the Windows start menu, something else? Give us the exact steps please.

What happened then? Did you get an error? Can you copy and paste the error, or if not possible, take a screenshot?

What is your environment? Trust me, you did not try "almost every env". What version of Windows are you running? Did you try temporarily disabling any anti-virus? How many versions of Python do you have? Did you install 3.9 and 3.11 from the Windows app store too?

@zooba @terryjreedy

stevendaprano avatar Oct 16 '22 07:10 stevendaprano

python idle not working/opening

Please describe what you did and what happened. Please be precise, it's not enough to say you tried "everything" and "still boom idle is not opening".

What did you do? Double-click a file, type a command at the command prompt, use the Windows start menu, something else? Give us the exact steps please.

What happened then? Did you get an error? Can you copy and paste the error, or if not possible, take a screenshot?

What is your environment? Trust me, you did not try "almost every env". What version of Windows are you running? Did you try temporarily disabling any anti-virus? How many versions of Python do you have? Did you install 3.9 and 3.11 from the Windows app store too?

@zooba @terryjreedy

here is a video https://user-images.githubusercontent.com/115407035/196025457-185b0e40-cf15-4eed-b88f-346f83bb8d32.mp4 and trying everything means - resetting my pc and trying it or using a VMware(aka virtual env) or trying it on another pc What is your environment? Trust me, you did not try "almost every env" ans- obviously not every only that which have windows store in it What version of Windows are you running? ans- windows 10 Did you try temporarily disabling any anti-virus? ans- yep , also tried without antivirus(by uninstalling antivirus) How many versions of Python do you have? ans- i have used a single version at a time Did you install 3.9 and 3.11 from the Windows app store too? ans - yup (also tried 3.8 and 3.7 too)

cursorhigh avatar Oct 16 '22 10:10 cursorhigh

Confirming this issue. Today noticed exactly the same problem: can't start IDLE anymore from the Start menu, no error, no anything. In the Start menu I click on "IDLE (Python 3.10)" entry and nothing happens. Can't say when was the last time I ran IDLE, maybe a week or couple ago, noticed this problem only today when tried to launch it.

OS - Windows 10 Pro 21H2 (OS Build 19044.2130) Python - 3.10.8 from Microsoft Store (the only Python installation on the system). In the Library tab of Microsoft Store, it displays that the entry "Python 3.10 (Python Software Foundation)" was modified on 2022-10-14.

Python 3.10.8 was released on 2022-10-11 according to the announcement. I don't know when it arrived to Microsoft Store, maybe couple days later. So maybe this bug/issue was introduced in 3.10.8 version.

Console version of Python from Command Prompt runs fine:

C:\Users\Administrator>python
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world")
hello world
>>>

Executing python -m idlelib from Command Prompt prints this:

C:\Users\Administrator>python -m idlelib
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\__main__.py", line 6, in <module>
    import idlelib.pyshell
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\pyshell.py", line 53, in <module>
    from idlelib import debugger
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\debugger.py", line 7, in <module>
    from idlelib import macosx
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\macosx.py", line 7, in <module>
    from test.support import requires, ResourceDenied
ModuleNotFoundError: No module named 'test'

Also similar output when running python -m idlelib.idle from Command Prompt:

C:\Users\Administrator>python -m idlelib.idle
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\idle.py", line 13, in <module>
    from idlelib.pyshell import main  # This is subject to change
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\pyshell.py", line 53, in <module>
    from idlelib import debugger
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\debugger.py", line 7, in <module>
    from idlelib import macosx
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\macosx.py", line 7, in <module>
    from test.support import requires, ResourceDenied
ModuleNotFoundError: No module named 'test'

50csent avatar Oct 16 '22 14:10 50csent

This issue is fixed for future releases by #98313. The problem is that https://github.com/python/cpython/pull/97530 fixed IDLE tests possibly crashing on a Mac without a GUI. But it resulted in IDLE not starting in 3.10.8, 3.12.0a1, and Microsoft Python 3.10.2288.0 when tests are not installed. After this patch, test.* is only imported when testing on Mac, which test.* must exist.

Fix 1: edit Lib/idlelib/macosx.py by making line 7 a comment and replacing line 23 with pass so that lines 4-25 become

from os.path import expanduser
import plistlib
from sys import platform  # Used in _init_tk_type, changed by test.
# from test.support import requires, ResourceDenied  # <- line 7 now a comment

import tkinter


## Define functions that query the Mac graphics type.
## _tk_type and its initializer are private to this section.

_tk_type = None

def _init_tk_type():
    """ Initialize _tk_type for isXyzTk functions.
    """
    global _tk_type
    if platform == 'darwin':
        try:
            pass  # <- line 23 replacement
        except ResourceDenied:  # Possible when testing.
            _tk_type = "cocoa"  # Newest and most common.

Alternatively, delete line 7 and the 4-line try-except block lines 22-25. Note that the path may be slightly different before idlelib on non-Windows systems and that admin privileges may be required, depending on how Python was installed.

Edit: 3.11.0, without the bug, was released today.
AFAIK, Windows Store Python omits the test package by default and perhaps always. This installer is produced by Microsoft, not by the Python Software Foundation (PSF) core developers. I do not know how often Microsoft updates it. I also do not know its install options and locations - Program Files or Users\user\AppData\???. I will edit this note if someone supplies more details @zooba Can you?

The PSF python.org Windows installer installs test/* by default. An alternate fix for someone who changed the default is to re-run the installer, select Modify, reselect 'Install tests', and click the install/continue/whatever button.

AFAIK, the PSF python.org Mac installer always installs test/*.

I don't know what *nix distributions do, but there should be an option to install tests if not the default.

terryjreedy avatar Oct 16 '22 15:10 terryjreedy

AFAIK, Windows Store Python omits the test package by default and perhaps always. This installer is produced by Microsoft, not by the Python Software Foundation (PSF) core developers. I do not know how often Microsoft updates it. I also do not know its install options and locations - Program Files or Users\user\AppData???. I will edit this note if someone supplies more details @zooba Can you?

This is our package, and I update it as part of doing the regular releases. So it'll get any updates at the same time (plus review by Microsoft Store team, which is typically only a day or two).

There's no option to include the test suite, and I don't really want to double the install size by adding it in. We shouldn't have dependencies on the test suite from the main stdlib code.

zooba avatar Oct 17 '22 16:10 zooba

Thanks; I edited the Store part of my answer above.

Continue omitting the test suite. The revised code only imports test on Mac and only when test.test_idle is run, when the import must succeed.

terryjreedy avatar Oct 17 '22 20:10 terryjreedy

I have a MicrosoftStore install, and I found the file in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\Lib\idlelib - however I managed to break the install while trying to persuade Windows to let me edit the file (I think app store apps have very convoluted ACLs to protect users from themselves?)

EDIT: On further investigation it appears that Windows just straight up won't let you edit files under WindowsApps, so Affected users will have to go the path of getting "test" instead... if I can work out how to get the Store to let me do that...

pmabbott avatar Oct 23 '22 20:10 pmabbott

@pmabbott The next release has a proper fix for this, but you can also copy the entire test package from the GitHub repo into your local site packages (check sys.path for the location - it'll be towards the end). This is roughly the equivalent of pip-installing the package.

zooba avatar Oct 24 '22 15:10 zooba

Hi another one to add to the fray, my IDLE was running up until approximately the above ticket was generated, I am curious if Python changed or an ms package changed? I will attempt to add the test package, but I have no admin rights on my machine. I will report back for other users. If ms Store can update the package asap that would be the best solution for users with no admin. Thanks!

grahammerrick-cwpr avatar Oct 25 '22 00:10 grahammerrick-cwpr

The file I suggested editing in https://github.com/python/cpython/issues/98324#issuecomment-1279990057 changed. If that is not possible, installing Python from python.org is possible for at least some people.

terryjreedy avatar Oct 25 '22 04:10 terryjreedy

The suggestion from @zooba works with a little bit of tweaking. Unfortunately, the site package path is within C:\Program Files\WindowsApps so is immutable. You can however set PYTHONPATH to add a directory somewhere OUTSIDE of that, and then put the test directory in there.

To summarise the workaround (Which I think does require admin rights in order to set PYTHONPATH):

  • Set PYTHONPATH at the OS level to point at/add a directory of your choice outside of C:\Program Files\WindowsApps (I picked C:\ppath (FWIW I'd never done that on Windows, and found out via a SO answer )
  • Drop a copy of ./Lib/test into that directory - that is, the test directory into the pathed directory not the content of the test directory into the pathed directory (so in my case I ended up with C:\ppath\test)
  • Start IDLE as before the bug

pmabbott avatar Oct 25 '22 23:10 pmabbott

Unfortunately, the site package path is within C:\Program Files\WindowsApps so is immutable

You'll also have one under C:\Users\<you>\AppData\Local\Packages\<long name> which is writable. This is where pip installs go by default, since the stdlib location is not writable. Easiest way to find the exact path is to look at your sys.path, because the name towards the end isn't really memorable.

zooba avatar Oct 25 '22 23:10 zooba

So rounding back on this one.. I managed to add to PYTHONPATH in CLI using the path command, with no Admin required, this solved the Path issue. (I couldn't get access to the Env Variables GUI in Advanced System Settings (CLI above solved that) and couldn't gain access to the C:\Program Files\WindowsApps folder, to place the test files without Admin privileges) I downloaded 3.10.8 windows installer direct from Python.org removed all Python installs from Windows, and installed Python 3.10.8 into the user directory (C:\Users<you>\AppData\Local\Programs\Python) unchecking the Admin privileges box. This allowed me to use IDLE again. So far all packages that I use have installed through pip with no issues. During my pursuit I attempted Python 3.11rc0 from the ms store but pip packages were failing, again due to Admin rights required!

Windows 10 Pro Version 21H2 OS Build 19044.2006 No Admin Rights!!

Python 3.10.8 Windows Installer from https://www.python.org/downloads/release/python-3108/ Oct 11, 2022 Successfully installed

grahammerrick-cwpr avatar Oct 26 '22 03:10 grahammerrick-cwpr

python.org got 3.11.0 yesterday

terryjreedy avatar Oct 26 '22 05:10 terryjreedy

python.org got 3.11.0 yesterday

ya it's so good

cursorhigh avatar Oct 26 '22 07:10 cursorhigh