pypa / pypa/setuptools

[BUG] Module Not Found for Python 3.12. It works in Python 3.10 for Setuptools version 65.5.0.

Open
#4,425 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Waiting User Feedback
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

70.0.0

Python version

Python 3.12

OS

Mac M2 Pro Max, Mac M1 Pro

Additional environment information

[metadata]
name = backend
description = backend
author = Kimchi
platforms = unix, linux, osx, win32
classifiers =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
version = 0.1.0

[options]
packages = find:
install_requires =
requests >= 2
python_requires = >=3.10

requirements.txt file

aiohttp==3.9.5
asyncio==3.4.3
boto3==1.34.122
fastapi==0.111.0
firebase-admin==6.5.0
google-cloud-storage==2.17.0
httpx==0.27.0
poetry==1.1.12
pre-commit==3.7.1
pytest==8.2.2
pytest==8.2.2
pytest-mock==3.14.0
requests
setuptools==70.0.0
uvicorn==0.30.1
wheel==0.43.0
gemini_webapi==1.5.1

Description

File Name: generate_background.py

from api.controllers.helpers import (
generate_background_aws,
generate_background_firebase,
generate_background_google,
)

This returns the error that ModuleNotFoundError: No module named 'api'

File Path:
src
--api
----controllers
------helpers
--------init.py
--------aws.py
--------firebase.py
--------gcs.py
------generate_background.py

In the helpers folder, The init file looks like

File Name: init.py

from .firebase import generate_background_firebase
from .gcs import generate_background_google

all = [
"generate_background_aws",
"generate_background_firebase",
"generate_background_google",
]

And the aws.py file has this kind of function:

File Name: aws

async def generate_background_aws()

Please let me know if any of the change I should make to make this work. Our team is wondering if we should downgrade our python version to 3.10 which worked for one member.

Expected behavior

We should be able to import the local modules correctly.

How to Reproduce

Just try to run the file after making the similar file and path structure. It returns an error....

Output
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/config.py", line 434, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/importer.py", line 22, in import_from_string
    raise exc from None
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/env/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/src/main.py", line 2, in <module>
    from .api.routes import image_router, text_router
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/src/api/__init__.py", line 1, in <module>
    from . import controllers, routes, utils
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/src/api/controllers/__init__.py", line 2, in <module>
    from .generate_background import generate_background
  File "/Users/taeyangkim/Dev/ai-video-gen/backend/src/api/controllers/generate_background.py", line 8, in <module>
    from helpers.aws import generate_background_aws
ModuleNotFoundError: No module named 'helpers'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/main.py and src/api/controllers/generate_background.py, then trace the import paths shown in the Uvicorn traceback. Reproduce the reported ModuleNotFoundError with the stated Python and setuptools versions, checking whether the failure is caused by project package configuration or setuptools. Done means providing a minimal reproduction and a verified cause or documented resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.