Python Forum
Start Idle in a virtual environment
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start Idle in a virtual environment
#1
This is a sad story.

Using my mobile phone and an app from Epson, I was setting up my printer to work with a new router. Everything was fine. Right at the end of setting up the printer, the app said: "New firmware is available. Do you want to install it?" I foolishly clicked "Yes". Something went wrong. The printer was left unusable. Epson knows about this problem. They have a software to reflash the printer, using a printer usb cable. Worked fine, but ...

But, somehow it flashed my bios, or at least my grub2 bootloader, away, I use Ubuntu 22.04 with grub bootloader. Grub was gone! I could not start Ubuntu 22.04.

On justanswer.co.uk I got help. AmareshK told me to switch the computer on and immediately and repeatedly press del. Worked, I entered the bios! I booted from a Ubuntu 24.04 boot stick, installed Ubuntu 24.04. The fact that justanswer.co.uk tried to take £35 from my bank account 3 days later and my bank contacted me about fraud is neither here nor there.

The Ubuntu 22.04 partition was somehow damaged and could not start. Using gparted in 24.04, I checked the partition, then I could boot 22.04

In Ubuntu 22.04, in bash, I use this bash command to start Python in a virtual environment:

Quote:pedro@pedro-MSI:~$ cd Python_Virtual_Environments && source GP_env/bin/activate && python -m idlelib.idle

This command does not work in 24.04, although everywhere I look on the internet says:

Quote:start Idle with: python -m idlelib.idle

In 24.04, which has Python 3.12 I get this:

peterr@peterr-Modern-15-B7M:~$ cd Python_Virtual_Environments && source GP_env/bin/activate && python3 -m idlelib.idle
/usr/bin/python3: Error while finding module specification for 'idlelib.idle' (ModuleNotFoundError: No module named 'idlelib')

Try to install idlelib:

Quote:(GP_env) peterr@peterr-Modern-15-B7M:~/Python_Virtual_Environments$ pip install idlelib
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Any tips please?

I also created a new VENV in 24.04, called GPE, but it will not start Idle, same problem.
Reply
#2
Try this perhaps
Output:
cd Python_Virtual_Environments && source GP_env/bin/activate && python3 -m pip install idlelib
This "error" happens because Ubuntu 24.04 adopted PEP 668
Pedroski55 likes this post
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
(May-30-2025, 07:22 PM)Pedroski55 Wrote: Any tips please?
General tips don't use IDLE🚽
(May-30-2025, 07:22 PM)Pedroski55 Wrote: I also created a new VENV in 24.04, called GPE, but it will not start Idle, same problem.
python3 -m venv --system-site-packages GPE
source GPE/bin/activate
python3 -m idlelib.idle
This works because the idle3 package (installed via apt) places idlelib in the system site-packages, and now your venv can see them.
Quote:pip install idlelib
idlelib isn’t a PyPI package then pip install ... will not work.
Idlelib module is no longer installed by default with the Python interpreter. It’s packaged separately.
sudo apt install idle3
Pedroski55 likes this post
Reply
#4
Thanks for your advice, but I still can't get Idle to start in 24.04.

I did these steps in Ubuntu 24.04:

Quote:peterr@peterr-Modern-15-B7M:~/PVE$ python3 -m venv --system-site-packages GPE
peterr@peterr-Modern-15-B7M:~/PVE$ source GPE/bin/activate
(GPE) peterr@peterr-Modern-15-B7M:~/PVE$ python3 -m idlelib.idle
/home/peterr/PVE/GPE/bin/python3: Error while finding module specification for 'idlelib.idle' (ModuleNotFoundError: No module named 'idlelib')

Same error as before.

Try to install idlelib as Gribouillis recommended:

Quote:(GPE) peterr@peterr-Modern-15-B7M:~/PVE$ python3 -m pip install idlelib
ERROR: Could not find a version that satisfies the requirement idlelib (from versions: none)
ERROR: No matching distribution found for idlelib

I know you guys don't like Idle, but I am not a programmer, just an interested user, doing simple things, Idle suits me and I am used to it.

Another little problem if I may: I need moderator help to get a new password. I can't login here on Ubuntu 24.04. I have 2 passwords saved in a text file, but when I try the older one or the newer one, I cannot set my email using either password. I login in here with the password saved by the browser, but I am not sure what that password is.

If I don't have an email in the system, the system can't send me a new password. I need to set my email here.
Reply
#5
After activate venv.
source ~/PVE/GPE/bin/activate
Try run system IDLE with full path,
/usr/bin/python3 -m idlelib.idle
This runs the system-installed IDLE, but because your venv is active,
anything you run or import inside IDLE will still use the venv's environment (e.g., installed packages, different paths, etc.).
Reply
#6
Thanks for your reply.

I tried

Quote:peterr@peterr-Modern-15-B7M:~/PVE$ source GPE/bin/activate
(GPE) peterr@peterr-Modern-15-B7M:~/PVE$ python3 -m idlelib.idle
/home/peterr/PVE/GPE/bin/python3: Error while finding module specification for 'idlelib.idle' (ModuleNotFoundError: No module named 'idlelib')

but it did not work. ModuleNotFoundError.

Also, I can't install idlelib

Quote:(GPE) peterr@peterr-Modern-15-B7M:~/PVE$ python3 -m pip install idlelib
ERROR: Could not find a version that satisfies the requirement idlelib (from versions: none)
ERROR: No matching distribution found for idlelib

But there is a script called idle.py

Quote:(GPE) peterr@peterr-Modern-15-B7M:~/PVE$ pip3.12 install idle
Requirement already satisfied: idle in ./GPE/lib/python3.12/site-packages (1.0.4)

Try to start idle gives the following error:

Quote:(GPE) peterr@peterr-Modern-15-B7M:~/PVE$ python3 -m idle
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/peterr/PVE/GPE/lib/python3.12/site-packages/idle.py", line 26, in <module>
gui.mainloop()
^^^
NameError: name 'gui' is not defined

The file /home/peterr/PVE/GPE/lib/python3.12/site-packages/idle.py looks like this:

import sys
import os
from layout import *

arguments = sys.argv

for args in arguments:
 if args=="--help" or args== "-h":
  print("""Help box for Idle by\033[34;1;40m Devesh Sharma\nIf you don't pass anything it will automatically run the program\n\033[37;1;40m--start to start the gui version\n--about or -a to get information about the program\n--clear or -c  to clear the screen\n--uninstall or -u to uninstall the module\n-- or -h help shows this manual""")

 elif args=="--about" or args=="-a":
  print("""\033[34;1;40mThis program is made by Devesh Sharma using the tkinter who lives in Panipat , Haryana located in India. He wants to provide a best coding experiences using python modules and makimg efforts to enhance its performance and this program is freely available on github Anybody who want to support is free to support in this program and anybody who wants to use this program can use this program in his programs or project or for anyuses without my permission. Regards to Readers
Thank You
A wish to Readers by Devesh Sharma
""")
 elif args=="--start" or args=="-s":
  gui.mainloop()

 elif args== "--clear" or args=="-c":
  os.system("clear")

 elif args=="--uninstall" or args=="-u":
  os.system("pip uninstall idle")

gui.mainloop()
Maybe this script needs a shebang?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I cannot create a virtual environment on visual studio code using python Willem_Aucamp316 2 4,688 Nov-27-2024, 02:20 PM
Last Post: menator01
  How to enable Matplotlib within virtual environment? tetris_theMovie 1 1,254 Oct-11-2024, 09:56 AM
Last Post: christie2
  Need help setting up trusted root ca in virtual environment dstempfley 0 1,388 May-31-2024, 03:14 PM
Last Post: dstempfley
  Help with creating folder and "virtual environment" AudunNilsen 1 1,150 Mar-21-2024, 04:41 AM
Last Post: deanhystad
  Installing python packages in a virtual environment Led_Zeppelin 1 1,784 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Problem with virtual environment standenman 2 2,511 Feb-23-2023, 07:09 PM
Last Post: standenman
Question Virtual Environment (using VS Code) Ashcora 4 77,924 Feb-15-2023, 07:17 PM
Last Post: snippsat
  Python Idle won't start totalmachine 9 6,192 Oct-16-2022, 05:57 PM
Last Post: totalmachine
  How do I link the virtual environment of that project to the 3.9.2 version of python? Bryant11 1 2,433 Feb-26-2022, 11:15 AM
Last Post: Larz60+
  Project structure with a virtual environment gdbengo 1 2,395 Jan-26-2022, 03:22 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020