Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13: ModuleNotFoundError: No module named 'cgi' (updating bottle should fix this) #4983

Closed
hroncok opened this issue Sep 23, 2024 · 5 comments
Milestone

Comments

@hroncok
Copy link

hroncok commented Sep 23, 2024

Configuration

Operating system: Fedora Linux 41

PlatformIO Version (platformio --version): 3.3.3

Description of problem

On Fedora Linux 41, we have upgraded to Python 3.13. Fedora Linux 41 is still in Beta, but users are already using PlatformIO and they report bugs:

I've reproduced the issue on Fedora 41. I do not use PlatformIO, I am merely the Python maintainer for Fedora.

Steps to Reproduce

  1. Get Fedora 41 Workstation, https://fedoraproject.org/workstation/download/?beta
  2. Install it to a VM, as there is not enough space on the live system to install Code and PlatformIO
  3. Follow https://code.visualstudio.com/docs/setup/linux#_rhel-fedora-and-centos-based-distributions
  4. Follow https://platformio.org/install/ide?install=vscode
  5. Upon error, follow the advice given (VSCode > Help > Toggle Developer Tools > Console) to get the full traceback

Alternatively, get another system where Python 3.13 is the Python used by Code and follow from step 4.

Actual Results


Error: Error: Compatible PlatformIO Core not found.
Reason: Could not run `/home/test/.platformio/penv/bin/platformio --help`.
Error: ModuleNotFoundError: Traceback (most recent call last):
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/platformio/__main__.py", line 103, in main
    cli()  # pylint: disable=no-value-for-parameter
    ~~~^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1077, in main
    with self.make_context(prog_name, args, **extra) as ctx:
         ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 943, in make_context
    self.parse_args(ctx, args)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1644, in parse_args
    rest = super().parse_args(ctx, args)
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1408, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
                  ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 2400, in handle_parse_result
    value = self.process_value(ctx, value)
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 2362, in process_value
    value = self.callback(ctx, self, value)
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1300, in show_help
    echo(ctx.get_help(), color=ctx.color)
         ~~~~~~~~~~~~^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 704, in get_help
    return self.command.get_help(self)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1325, in get_help
    self.format_help(ctx, formatter)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1358, in format_help
    self.format_options(ctx, formatter)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1564, in format_options
    self.format_commands(ctx, formatter)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/click/core.py", line 1617, in format_commands
    cmd = self.get_command(ctx, subcommand)
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/platformio/cli.py", line 94, in get_command
    module = importlib.import_module(commands[cmd_name])
  File "/usr/lib64/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/platformio/commands/ci.py", line 24, in <module>
    from platformio.project.commands.init import project_init_cmd, validate_boards
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/platformio/project/commands/init.py", line 31, in <module>
    from platformio.project.integration.generator import ProjectGenerator
  File "/home/test/.platformio/penv/lib64/python3.13/site-packages/platformio/project/integration/generator.py", line 19, in <module>
    import bottle
  File "/home/test/.platformio/penv/bin/bottle.py", line 38, in <module>
    import base64, cgi, email.utils, functools, hmac, itertools, mimetypes,\
            os, re, subprocess, sys, tempfile, threading, time, warnings, hashlib
ModuleNotFoundError: No module named 'cgi'

Expected Results

PlatformIo install and works with Python 3.13.

Additional info

This is caused by bottlepy/bottle#1403 which was patched upstream in bottlepy/bottle#1438 and released as bottle 0.13.0. Updating the presumably vendored bottle should fix this.

@ivankravets
Copy link
Member

Fixed in 4230b22

Please re-test with pio upgrade --dev. Does it work now?

@ivankravets ivankravets added this to the 6.1.16 milestone Sep 23, 2024
@hroncok
Copy link
Author

hroncok commented Sep 23, 2024

How do I do pio upgrade --dev? I am not a user of Code and I need a very specific set of instructions, sorry.

@ivankravets
Copy link
Member

$ /home/test/.platformio/penv/bin/pip install -U https://github.com/platformio/platformio-core/archive/refs/heads/develop.zip

WITHOUT SUDO

@hroncok
Copy link
Author

hroncok commented Sep 23, 2024

The pip install --upgrade succeeds. After that, PlatformIO appears to be installed in Code. Thanks.

@ivankravets
Copy link
Member

Thanks for the confirmation. We will bump the new PIO Core release this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants