You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project structured with a central pkg directory and a tools directory containing Knative functions that depend on code within the pkg directory. Specifically, I'm utilizing the Flask function template. In my func.py file, I attempt to perform a relative import as follows:
Executing func.py directly with python func.py works without issues. However, running the function using func run results in an import error:
Building function image
Still building
🙌 Function built: index.docker.io/sdf/create:latest
Running on host port 8080
[2025-03-23 19:02:07 +0000] [1] [INFO] Starting gunicorn 22.0.0
[2025-03-23 19:02:07 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2025-03-23 19:02:07 +0000] [1] [INFO] Using worker: sync
[2025-03-23 19:02:07 +0000] [22] [INFO] Booting worker with pid: 22
DIR /
[2025-03-23 19:02:07 +0000] [22] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.10/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
worker.init_process()
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/workspace/func.py", line 11, in <module>
from pkg.core.func_creator import FunctionCreator
ModuleNotFoundError: No module named 'pkg'
[2025-03-23 19:02:07 +0000] [22] [INFO] Worker exiting (pid: 22)
[2025-03-23 19:02:07 +0000] [1] [ERROR] Worker (pid:22) exited with code 3
[2025-03-23 19:02:07 +0000] [1] [ERROR] Shutting down: Master
[2025-03-23 19:02:07 +0000] [1] [ERROR] Reason: Worker failed to boot.
Expected Behavior:
The function should execute successfully, resolving the relative imports without errors
Actual Behavior:
The function fails to run, producing an import error indicating that the pkg module cannot be found
The text was updated successfully, but these errors were encountered:
Description:
I have a project structured with a central
pkg
directory and atools
directory containing Knative functions that depend on code within thepkg
directory. Specifically, I'm utilizing the Flask function template. In myfunc.py
file, I attempt to perform a relative import as follows:Executing
func.py
directly withpython func.py
works without issues. However, running the function usingfunc run
results in an import error:Expected Behavior:
The function should execute successfully, resolving the relative imports without errors
Actual Behavior:
The function fails to run, producing an import error indicating that the
pkg
module cannot be foundThe text was updated successfully, but these errors were encountered: