Score:2

Ubuntu server 23.04 netplan cloud-init python error

sl flag

I've tried to find a solution and an answer myself before but didn't succeed.

I recently changed my wi-fi SSID and thus had to reflect that change in my ubuntu server configs.

On the raspi 4 everything worked as intended and the device connected to the new SSID.

On the raspi 3 I repeated the same steps as on the rapi 4 however any command related to netplan or cloud-init results in a traceback error being thrown at me.

System setup and state

  • running Ubuntu server 23.04 on two raspberry pi (3 and 4)
  • both systems are up to date
  • changed config in both /boot/firmware/network-config files to reflect the new SSIDs
  • tripple checked for any syntax errors or issues with indentation
  • executed netplan try and netplan apply

Problem description

  • Executing any netplan or cloud-init command will output errors. Even when I try to just run very basic netplan -h or cloud-init -h the same errors appear.

See log below:

> netplan -h
Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 48, in main
    self.parse_args()
  File "/usr/share/netplan/netplan/cli/core.py", line 41, in parse_args
    import netplan.cli.commands
  File "/usr/share/netplan/netplan/cli/commands/__init__.py", line 21, in <module>
    from netplan.cli.commands.migrate import NetplanMigrate
  File "/usr/share/netplan/netplan/cli/commands/migrate.py", line 26, in <module>
    import yaml
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1069, in get_code
  File "<frozen importlib._bootstrap_external>", line 729, in _compile_bytecode
EOFError: marshal data too short
> cloud-init -h
Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 33, in <module>
    sys.exit(load_entry_point('cloud-init==23.2.1', 'console_scripts', 'cloud-init')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/cloud-init", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 27, in <module>
    from cloudinit.config.modules import Modules
  File "/usr/lib/python3/dist-packages/cloudinit/config/modules.py", line 14, in <module>
    from cloudinit import config, importer
  File "/usr/lib/python3/dist-packages/cloudinit/importer.py", line 15, in <module>
    from cloudinit import util
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 46, in <module>
    from cloudinit import (
  File "/usr/lib/python3/dist-packages/cloudinit/safeyaml.py", line 11, in <module>
    import yaml
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1069, in get_code
  File "<frozen importlib._bootstrap_external>", line 729, in _compile_bytecode
EOFError: marshal data too short
  • checked /var/log/syslog just to find more apparently python3 related errors i.e. in apt_news.py and esm_cache.py

What I have tried so far

  • re-installing netplan, cloud-init and even python using apt --reinstall install <package>
  • purged netplan and cloud-init and re-installed it
  • checked for any missing or broken packages

To my very limited knowledge it looks like there is some general python error happening but I have no clue on how to resolve it. Please consider my linux/ubuntu knowlegde rather basic having worked myself through many hours of tutorials during the pandemic to set up the raspberry pi as a home server.

I would appreciate any input or hint that might lead me into the right direction :)

Roko C. Buljan avatar
us flag
Experiencing the same thing on Arch.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.