-2

Thonny fails to load on my new RPi CM4, tried sudo apt update && sudo apt upgrade -y, that successfully applied a huge update, but Thonny still fails:` d

aves@raspberrypi:~ $ thonny 16:46:28.427 [MainThread] INFO thonny: Thonny version: 4.1.4 16:46:28.427 [MainThread] INFO thonny: cwd: /home/daves 16:46:28.428 [MainThread] INFO thonny: original argv: ['/usr/bin/python3', '/usr/bin/thonny'] 16:46:28.428 [MainThread] INFO thonny: sys.executable: /usr/bin/python3 16:46:28.428 [MainThread] INFO thonny: sys.argv: ['/usr/bin/thonny'] 16:46:28.428 [MainThread] INFO thonny: sys.path: ['/usr/bin', '/usr/lib/python311.zip', '/usr/lib/python3.11', '/usr/lib/python3.11/lib-dynload', '/usr/local/lib/python3.11/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.11/dist-packages'] 16:46:28.428 [MainThread] INFO thonny: sys.flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0, dev_mode=False, utf8_mode=0, warn_default_encoding=0, safe_path=False, int_max_str_digits=-1) Traceback (most recent call last): File "/usr/lib/python3/dist-packages/thonny/__init__.py", line 266, in launch _delegate_to_existing_instance(sys.argv[1:]) File "/usr/lib/python3/dist-packages/thonny/__init__.py", line 353, in _delegate_to_existing_instance sock, secret = _create_client_socket() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/thonny/__init__.py", line 396, in _create_client_socket client_socket.connect(get_ipc_file_path()) ConnectionRefusedError: [Errno 111] Connection refused 16:46:28.605 [MainThread] INFO thonny.workbench: Starting Workbench ERROR:root:Internal launch or mainloop error Traceback (most recent call last): File "/usr/lib/python3/dist-packages/thonny/__init__.py", line 279, in launch bench = workbench.Workbench() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/thonny/workbench.py", line 132, in __init__ tk.Tk.__init__(self, className="Thonny") File "/usr/lib/python3.11/tkinter/__init__.py", line 2326, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _tkinter.TclError: no display name and no $DISPLAY environment variable Traceback (most recent call last): File "/usr/lib/python3/dist-packages/thonny/__init__.py", line 279, in launch bench = workbench.Workbench() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/thonny/workbench.py", line 132, in __init__ tk.Tk.__init__(self, className="Thonny") File "/usr/lib/python3.11/tkinter/__init__.py", line 2326, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _tkinter.TclError: no display name and no $DISPLAY environment variable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/thonny", line 33, in <module> sys.exit(load_entry_point('thonny==4.1.4', 'gui_scripts', 'thonny')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/thonny/__init__.py", line 291, in launch dlg = ui_utils.LongTextDialog("Internal error", traceback.format_exc()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/thonny/ui_utils.py", line 1858, in __init__ super().__init__(master=parent) File "/usr/lib/python3/dist-packages/thonny/ui_utils.py", line 37, in __init__ assert master AssertionError ` 
6
  • Thanks, Dirk, I am only attempting to run Thonny from the command line from a putty connection, is because the CM4 will not open the desktop when I boot it. So the question probably should have been why the CM4 only displays the splashscreen and then nothing... Commented Nov 9 at 18:55
  • 1
    Thonny is a GUI application; it NEEDS a Desktop. Absolutely NOTHING to do with CM4 Commented Nov 9 at 21:32
  • Thanks - I now realise that - will try booting CM4 from eMMC rather than SD card Commented Nov 11 at 9:43
  • Why am I using a CM4? - I am trying to develop a low-cost traffic speed camera in python based on a roadside CM4. I have used Thonny and quite like it.. I find editing a python script in nano and running from the command line is just too long-winded when trying to debug the code. So I repeat my underlying question: why won't my CM4 boot into the Pi desktop? (from which I could run Thonny and make some progress) Commented Nov 13 at 10:01
  • Thank you..The CM4 is mounted on a Waveshare XM4-IO-BASE-C (V2) baseboard connected (and hence powered) via the USB-C socket to a Windows 11 PC. The problems start from attempting to run RPIBoot, which fails to recognise the CM4: "Fails to read 12711/bootcode.bin", hence no chance that RPIimager can access the CM4 to update the eMMC memory. Commented Nov 14 at 13:39

1 Answer 1

0

As others have said, trying to run thorny from a CLI won't work. It needs a UI. Use nano, VIM, SED, Micro, or any other well-established editor for CLI file changes.

To your other comments, the reason for "wont display desktop when booting" has something to do with your configuration or the chosen image. Using an SD card or EMMC as the boot partition should have no effect on being able to boot into a UI with any of the standard RPI images. If the display isn't showing a CLI at a minimum then there's also something wrong with your config file (many of the generic displays require some additional modifications).

Lastly, for your comment about not being able to use the Raspberry Pi Imager to flash the EMMC, make sure the boot jumper on the board is set. There's great instructions out there for all of these things. You've only kind of half-explained what you're doing though so everyone's taking best-guesses at what might be the issue. Posting something like "I followed X-guide" and "tried troubleshooting using Y-steps" will let others provide better input.

4
  • There is a BOOT ON/OFF switch on the Waveshare CM4-IO-BASE-C (V2) baseboard: powering up with the switch set to ON, the CM4 does absolutely nothing; with it it set to OFF - the CM4 boots (taking 0.34A at 5.18V from my PSU, and responds correctly to a putty request to its IP address (but no desktop is displayed after the splashscreen). Commented Nov 15 at 16:13
  • I am following this guide: raspberrypi.com/documentation/computers/… Commented Nov 15 at 16:13
  • The TF card is a Sandisk Ultra 32GB, loaded with PiOS (32-bit), (A port of Debian Trixie with the Raspberry Pi Desktop) released 2025-10-01 using the Raspberry Pi Imager v1.9.6. I have also tried the 64-bit OS with the same results. I select the Raspberry Pi 4 Device and the SDHC SCSI DISK Device. Under Edit Settings, I select a username and password (which both work with on the putty connection), No Wireless LAN, Time Zone = Europe/London, Keyboard layout = gb. Please advise what config changes may be required and where. Commented Nov 15 at 16:28
  • The correct guide for the CM4/CM5 flash to EMMC is here. With the "boot" switch in the on position, you'll use rpiboot in order to recognize the EMMC as a storage device. THEN you can use the Raspberry Pi Imager to flash to EMMC. For any configuration settings, consult the documentation for your display. It'll tell you if the config.txt file needs changes to work with the display or not. Commented Nov 15 at 19:27

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.