[GH-ISSUE #4949] import UTC from datetime ERROR #52464

Closed
opened 2026-05-05 13:33:02 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @jonstevet on GitHub (Aug 27, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/4949

Bug Report

error excute bash start, after upgrade from 0.3.13 to v0.3.16
File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in
from datetime import datetime, timedelta, UTC
ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py)

Installation Method

git clone
git update
[Describe the method you used to install the project, e.g., git clone, Docker, pip, etc.]

Environment

  • **Open WebUI Version: v0.3.13

  • **Ollama (if applicable): v0.3.6

  • **Operating System: Ubuntu server 22.04.4 LTS

  • **Browser (if applicable): Chrome

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

start the app

Actual Behavior:

not start

Description

Bug Summary:
error excute bash start, after upgrade from 0.3.13 to v0.3.16
File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in
from datetime import datetime, timedelta, UTC
ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py)

Reproduction Details

Steps to Reproduce:
error excute bash start, after upgrade from 0.3.13 to v0.3.16
File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in
from datetime import datetime, timedelta, UTC
ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py)

Logs and Screenshots

#log error

(openwebui) (base) administrador@sabila2:~/open-webui/backend$ bash start.sh
start.sh: line 2: ./.env: No such file or directory
Loading WEBUI_SECRET_KEY from file, not provided as an environment variable.
Loading WEBUI_SECRET_KEY from .webui_secret_key
/home/administrador/open-webui
Traceback (most recent call last):
  File "/home/administrador/.local/bin/uvicorn", line 8, in <module>
    sys.exit(main())
  File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/main.py", line 410, in main
    run(
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/main.py", line 578, in run
    server.run()
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/server.py", line 68, in serve
    config.load()
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/config.py", line 473, in load
    self.loaded_app = import_from_string(self.app)
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/importer.py", line 24, in import_from_string
    raise exc from None
  File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
  File "/usr/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 "/home/administrador/open-webui/backend/main.py", line 30, in <module>
    from apps.socket.main import app as socket_app, get_event_emitter, get_event_call
  File "/home/administrador/open-webui/backend/apps/socket/main.py", line 6, in <module>
    from utils.utils import decode_token
  File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in <module>
    from datetime import datetime, timedelta, UTC
ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py)
(openwebui) (base) administrador@sabila2:~/open-webui/backend$ 

Additional Information

solve whit:
file: open-webui/backend/utils/utils.py (ln 9)

ln09 from datetime import datetime, timedelta, UTC ---> **from datetime import datetime, timedelta, timezone **

ln17 UTC = timezone.utc #new line

Note

If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!

Originally created by @jonstevet on GitHub (Aug 27, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/4949 # Bug Report error excute bash start, after upgrade from 0.3.13 to v0.3.16 File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in <module> from datetime import datetime, timedelta, UTC ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py) ## Installation Method git clone git update [Describe the method you used to install the project, e.g., git clone, Docker, pip, etc.] ## Environment - **Open WebUI Version: v0.3.13 - **Ollama (if applicable): v0.3.6 - **Operating System: Ubuntu server 22.04.4 LTS - **Browser (if applicable): Chrome **Confirmation:** - [x] I have read and followed all the instructions provided in the README.md. - [x] I am on the latest version of both Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: start the app ## Actual Behavior: not start ## Description **Bug Summary:** error excute bash start, after upgrade from 0.3.13 to v0.3.16 File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in <module> from datetime import datetime, timedelta, UTC ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py) ## Reproduction Details **Steps to Reproduce:** error excute bash start, after upgrade from 0.3.13 to v0.3.16 File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in <module> from datetime import datetime, timedelta, UTC ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py) ## Logs and Screenshots #log error ``` (openwebui) (base) administrador@sabila2:~/open-webui/backend$ bash start.sh start.sh: line 2: ./.env: No such file or directory Loading WEBUI_SECRET_KEY from file, not provided as an environment variable. Loading WEBUI_SECRET_KEY from .webui_secret_key /home/administrador/open-webui Traceback (most recent call last): File "/home/administrador/.local/bin/uvicorn", line 8, in <module> sys.exit(main()) File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__ return self.main(*args, **kwargs) File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/administrador/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/main.py", line 410, in main run( File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/main.py", line 578, in run server.run() File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/server.py", line 68, in serve config.load() File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/config.py", line 473, in load self.loaded_app = import_from_string(self.app) File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/importer.py", line 24, in import_from_string raise exc from None File "/home/administrador/.local/lib/python3.10/site-packages/uvicorn/importer.py", line 21, in import_from_string module = importlib.import_module(module_str) File "/usr/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 "/home/administrador/open-webui/backend/main.py", line 30, in <module> from apps.socket.main import app as socket_app, get_event_emitter, get_event_call File "/home/administrador/open-webui/backend/apps/socket/main.py", line 6, in <module> from utils.utils import decode_token File "/home/administrador/open-webui/backend/utils/utils.py", line 9, in <module> from datetime import datetime, timedelta, UTC ImportError: cannot import name 'UTC' from 'datetime' (/usr/lib/python3.10/datetime.py) (openwebui) (base) administrador@sabila2:~/open-webui/backend$ ``` ## Additional Information solve whit: file: open-webui/backend/utils/utils.py (ln 9) ln09 **from datetime import datetime, timedelta, UTC** ---> **from datetime import datetime, timedelta, *timezone* ** ln17 **UTC = timezone.utc** #new line ## Note If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!
Author
Owner

@tjbck commented on GitHub (Aug 27, 2024):

Only python 3.11 is supported for Open WebUI and 3.10 is not officially supported.

<!-- gh-comment-id:2313481487 --> @tjbck commented on GitHub (Aug 27, 2024): Only python 3.11 is supported for Open WebUI and 3.10 is not officially supported.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#52464