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

Unable to import extensions in Python 3.12 / ModuleNotFoundError #1430

Open
brentvollebregt opened this issue Oct 5, 2023 · 1 comment
Open

Comments

@brentvollebregt
Copy link

After upgrading to Python 3.12, importing an extension, for example from bottle.ext.websocket import websocket, now gives the following error:

Traceback (most recent call last):
  File "C:\...\test.py", line 1, in <module>
    from bottle.ext.websocket import websocket
ModuleNotFoundError: No module named 'bottle.ext.websocket'

My environment:

  • Windows 10
  • Python 3.12.0
  • bottle 0.12.25
  • bottle-websocket 0.2.9 (the example extension)

Reproduction:

  1. Install dependencies: pip install bottle==0.12.25 bottle-websocket==0.2.9
  2. Run script:
    from bottle.ext.websocket import websocket

Investigation / Potential Solution:

I see this error does not occur on master but it does on the release-0.12 branch / 0.12.25 tag. Using the changes from ca6762c that are currently on master seems to fix this issue.

@brentvollebregt brentvollebregt changed the title ModuleNotFoundError: No module named 'bottle.ext.[extension]' Unable to import extensions in Python 3.12 Oct 7, 2023
@brentvollebregt brentvollebregt changed the title Unable to import extensions in Python 3.12 Unable to import extensions in Python 3.12 / ModuleNotFoundError Oct 7, 2023
@brentvollebregt
Copy link
Author

To add more info to this, I see support for the find_module API has been removed in Python 3.12 as noted in the changelog here:

Support for find_loader() and find_module() APIs have been removed. (Contributed by Barry Warsaw in gh-98040.)

The changelog recommends using find_spec() instead.

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

1 participant