Skip to content

Main Module not found - App/Backend startup error #1990

@luhgit

Description

@luhgit

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [x] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I simply cloned the repo and did azd up in my internal azure subscription which went successfully but something is wrong within the app code. It complains that it did not find main module. Here is the deployment logs:

user@MacBook-Pro-2  project/app  azd up  

Packaging services (azd package)

  (✓) Done: Packaging service backend
  - Package Output: /var/folders/wk/gl21l0hx06ng1z9g8h5yvvbw0000gn/T/azure-search-openai-demo-backend-azddeploy-1727257032.zip
Checking if authentication should be setup...
Loading azd .env file from current environment...
AZURE_USE_AUTHENTICATION is not set, skipping authentication setup.

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

Subscription: <hidden>
Location: West Europe

  You can view detailed progress in the Azure Portal:
  https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/overview/id/<hidden>

  (✓) Done: Resource group: rg-app (559ms)
  (✓) Done: Log Analytics workspace: log-<hidden> (1.382s)
  (✓) Done: App Service plan: plan-<hidden> (9.399s)
  (✓) Done: Azure OpenAI: cog-<hidden> (19.906s)
  (✓) Done: Azure AI Services Model Deployment: cog-<hidden>/chat (20.583s)
  (✓) Done: Azure AI Services Model Deployment: cog-<hidden>/embedding (21.121s)
  (✓) Done: Storage account: <hidden> (24.987s)
  (✓) Done: Document Intelligence: cog-di-<hidden> (35.697s)
  (✓) Done: Application Insights: appi-<hidden> (2.687s)
  (✓) Done: Portal dashboard: dash-<hidden> (878ms)
  (✓) Done: Search service: app-<hidden> (6m42.01s)
  (✓) Done: App Service: app-backend-<hidden> (32.358s)
Loading azd .env file from current environment...
Creating Python virtual environment "app/backend/.venv"...
Installing dependencies from "requirements.txt" into virtual environment (in quiet mode)...
Not updating authentication.
Loading azd .env file from current environment...
Creating Python virtual environment "app/backend/.venv"...
Installing dependencies from "requirements.txt" into virtual environment (in quiet mode)...
Running "prepdocs.py"
Connecting to Azure services using the azd credential for tenant <hidden>
Using local files: ./data/*
Ensuring search index <hidden> exists
Creating <hidden> search index
Ingesting 'test.json'
Splitting 'test.json' into sections
Uploading blob for whole file -> test.json
Computed embeddings in batch. Batch size: 1, Token count: 205

Deploying services (azd deploy)

  (✓) Done: Deploying service backend
  - Endpoint: https://app-backend-4w4vm3yqccwzs.azurewebsites.net/


SUCCESS: Your up workflow to provision and deploy to Azure completed in 42 minutes 30 seconds.

Any log messages given by the failure

2024-09-25T09:56:17.930486492Z    _____
2024-09-25T09:56:17.930541992Z   /  _  \ __________ _________   ____
2024-09-25T09:56:17.930549192Z  /  /_\  \\___   /  |  \_  __ \_/ __ \
2024-09-25T09:56:17.930553092Z /    |    \/    /|  |  /|  | \/\  ___/
2024-09-25T09:56:17.930556992Z \____|__  /_____ \____/ |__|    \___  >
2024-09-25T09:56:17.930560992Z         \/      \/                  \/
2024-09-25T09:56:17.930564992Z A P P   S E R V I C E   O N   L I N U X
2024-09-25T09:56:17.930578993Z
2024-09-25T09:56:17.930582593Z Documentation: http://aka.ms/webapp-linux
2024-09-25T09:56:17.930612193Z Python 3.11.8
2024-09-25T09:56:17.930615993Z Note: Any data outside '/home' is not persisted
2024-09-25T09:56:24.528821453Z Starting OpenBSD Secure Shell server: sshd.
2024-09-25T09:56:24.641121640Z WEBSITES_INCLUDE_CLOUD_CERTS is not set to true.
2024-09-25T09:56:24.994930298Z Site's appCommandLine: python3 -m gunicorn main:app
2024-09-25T09:56:24.994963998Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'python3 -m gunicorn main:app'
2024-09-25T09:56:25.339059943Z Could not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2024-09-25T09:56:25.339107644Z Could not find operation ID in manifest. Generating an operation id...
2024-09-25T09:56:25.339114744Z Build Operation ID: d962e851-5386-41c1-a1f2-f2330a7dd3b4
2024-09-25T09:56:27.477496534Z Oryx Version: 0.2.20240501.1, Commit: f83f88d3cfb8bb6d3e2765e1dcd218eb0814a095, ReleaseTagName: 20240501.1
2024-09-25T09:56:27.524517751Z Writing output script to '/opt/startup/startup.sh'
2024-09-25T09:56:27.608333071Z WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv.
2024-09-25T09:56:27.618207479Z WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__.
2024-09-25T09:56:32.837241073Z [2024-09-25 09:56:32 +0000] [63] [INFO] Starting gunicorn 22.0.0
2024-09-25T09:56:32.838393186Z [2024-09-25 09:56:32 +0000] [63] [INFO] Listening at: http://0.0.0.0:8000 (63)
2024-09-25T09:56:32.856766987Z [2024-09-25 09:56:32 +0000] [63] [INFO] Using worker: sync
2024-09-25T09:56:32.876054399Z [2024-09-25 09:56:32 +0000] [68] [INFO] Booting worker with pid: 68
2024-09-25T09:56:33.054835361Z [2024-09-25 09:56:32 +0000] [68] [ERROR] Exception in worker process
2024-09-25T09:56:33.054874462Z Traceback (most recent call last):
2024-09-25T09:56:33.054880162Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
2024-09-25T09:56:33.054884962Z     worker.init_process()
2024-09-25T09:56:33.054888562Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/workers/base.py", line 134, in init_process
2024-09-25T09:56:33.054892462Z     self.load_wsgi()
2024-09-25T09:56:33.054913262Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2024-09-25T09:56:33.054917762Z     self.wsgi = self.app.wsgi()
2024-09-25T09:56:33.054921262Z                 ^^^^^^^^^^^^^^^
2024-09-25T09:56:33.054924762Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi
2024-09-25T09:56:33.054928562Z     self.callable = self.load()
2024-09-25T09:56:33.054931962Z                     ^^^^^^^^^^^
2024-09-25T09:56:33.054935563Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2024-09-25T09:56:33.054939163Z     return self.load_wsgiapp()
2024-09-25T09:56:33.054942563Z            ^^^^^^^^^^^^^^^^^^^
2024-09-25T09:56:33.054945963Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2024-09-25T09:56:33.054949663Z     return util.import_app(self.app_uri)
2024-09-25T09:56:33.054953163Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-25T09:56:33.054956763Z   File "/opt/python/3/lib/python3.11/site-packages/gunicorn/util.py", line 371, in import_app
2024-09-25T09:56:33.054960463Z     mod = importlib.import_module(module)
2024-09-25T09:56:33.054963963Z           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-25T09:56:33.054967363Z   File "/opt/python/3/lib/python3.11/importlib/__init__.py", line 126, in import_module
2024-09-25T09:56:33.054971063Z     return _bootstrap._gcd_import(name[level:], package, level)
2024-09-25T09:56:33.054974663Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-25T09:56:33.054978163Z   File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
2024-09-25T09:56:33.054982363Z   File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
2024-09-25T09:56:33.054991963Z   File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
2024-09-25T09:56:33.054995663Z ModuleNotFoundError: No module named 'main'
2024-09-25T09:56:33.054999263Z [2024-09-25 09:56:33 +0000] [68] [INFO] Worker exiting (pid: 68)
2024-09-25T09:56:33.755608953Z [2024-09-25 09:56:33 +0000] [63] [ERROR] Worker (pid:68) exited with code 3
2024-09-25T09:56:33.755651653Z [2024-09-25 09:56:33 +0000] [63] [ERROR] Shutting down: Master
2024-09-25T09:56:33.755658153Z [2024-09-25 09:56:33 +0000] [63] [ERROR] Reason: Worker failed to boot.

Expected/desired behavior

That app starts without main module error.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
Running locally on MacOS (Sonoma) and in cloud on Linux.

azd version?

run azd version and copy paste here.
azd version 1.10.1 (commit 31409a33266fb4a5fdbb644bc83988e725d6c7c9)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions