You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove idlelib from sys.path in IDLE run process #134300
When use IDLE to open a file and start a new IDLE windows from "Python Shell" button, you can import the modules that are the child modules in the module "idlelib", such as "help", "pyshell". Think for that there are many schools still use IDLE to teach python to prevent the students to install malicious plugins from other IDE, if the students try to import these modules, it will result in misleading.
import help
This code is wrong in cmd and any other IDE but "normal" in IDLE, and what is imported is "idlelib.help".
Hi, there's a quick suggestion - the title of the issue should be more descriptive about the topic, rather than a very generic question, so the triagers and core devs can understand what's the issue about (whether it's in their area of expertise) without clicking into it.
Which version of Python are you using? And what OS are you on?
On macOS I get:
Python 3.12.10 (v3.12.10:0cc81280367, Apr 8 2025, 08:46:59) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Enter "help" below or click "Help" above for more information.
import help
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import help
ModuleNotFoundError: No module named 'help'
This is a subissue of #69674; I am leaving this open to patch this specific issue, which is that .../idlelib is sometimes on sys.path in the separate user process where user code is normally executed. ('Normally', means when option -n is not added to IDLE startup.) I noted in 2015 that this depends on how IDLE is started; and added today that it may have changed with version. It also depends the system. With 3.14 on my Win 10, >>> import help works. On my macbook with Catalina, it raises as Ronald shows above. (Note to anyone else: the splash line Enter "help" below ... is IDLE Shell specific.) Checking sys.path (most easily with for p in sys.path: print(p) shows that .../idlelib is present on Windows but not on Mac.
Since idlelib is only sometimes present, and idlelib.run runs when it is absent, it must not depend on it being present. Therefore safe to remove. User code depending on its presence is buggy in not running without IDLE. User code failing because of its presence has a legitimate complaint.
Activity
gaogaotiantian commentedon May 20, 2025
Hi, there's a quick suggestion - the title of the issue should be more descriptive about the topic, rather than a very generic question, so the triagers and core devs can understand what's the issue about (whether it's in their area of expertise) without clicking into it.
picnixz commentedon May 20, 2025
cc @terryjreedy I don't understand the issue but since it seems to be IDLE related, I'm pinging you to have a look and decide the scope.
ronaldoussoren commentedon May 20, 2025
Which version of Python are you using? And what OS are you on?
On macOS I get:
terryjreedy commentedon May 20, 2025
This is a subissue of #69674; I am leaving this open to patch this specific issue, which is that
.../idlelibis sometimes on sys.path in the separate user process where user code is normally executed. ('Normally', means when option-nis not added to IDLE startup.) I noted in 2015 that this depends on how IDLE is started; and added today that it may have changed with version. It also depends the system. With 3.14 on my Win 10,>>> import helpworks. On my macbook with Catalina, it raises as Ronald shows above. (Note to anyone else: the splash lineEnter "help" below ...is IDLE Shell specific.) Checking sys.path (most easily withfor p in sys.path: print(p)shows that.../idlelibis present on Windows but not on Mac.@Locked-chess-official What OS, python version, and IDLE startup method did you use.
I think adding the following to idlelib.run near the top should work.
[-]Is it needs to be fixed or writed in docs for warning?[/-][+]Remove idlelib from sys.path in IDLE run process[/+]Locked-chess-official commentedon May 21, 2025
Windows, 3.12 and 3.13
Locked-chess-official commentedon May 21, 2025
terryjreedy commentedon Dec 12, 2025
Since idlelib is only sometimes present, and idlelib.run runs when it is absent, it must not depend on it being present. Therefore safe to remove. User code depending on its presence is buggy in not running without IDLE. User code failing because of its presence has a legitimate complaint.
gh-134300: Remove idlelib from the path of the IDLE user process (#15…
[3.13] gh-134300: Remove idlelib from the path of the IDLE user proce…
[3.15] gh-134300: Remove idlelib from the path of the IDLE user proce…
[3.14] gh-134300: Remove idlelib from the path of the IDLE user proce…