arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.63k stars 669 forks source link

arrow 1.2.3 doesn't run under Python 3.11 #1161

Closed tammyalexandra closed 9 months ago

tammyalexandra commented 11 months ago

Issue Description

arrow 1.3.2 no longer works under Python 3.11 due to its dependency on python-datetime-tz.

When I try to start up a web server, the import arrow call fails:

> python manage.py runserver
Exception in thread django-main-thread:
Traceback (most recent call last):
...
  File "/Users/.../.../models.py", line 1, in <module>
    import arrow
  File "/usr/local/lib/python3.11/site-packages/arrow/__init__.py", line 2, in <module>
    from .api import get, now, utcnow
  File "/usr/local/lib/python3.11/site-packages/arrow/api.py", line 12, in <module>
    from arrow.arrow import TZ_EXPR, Arrow
  File "/usr/local/lib/python3.11/site-packages/arrow/arrow.py", line 32, in <module>
    from dateutil import tz as dateutil_tz
  File "/usr/local/lib/python3.11/site-packages/dateutil/tz.py", line 78
    `self._name`,
    ^
SyntaxError: invalid syntax

When I try to reinstall arrow to update the dependencies, it fails as follows:

> pip install arrow
Requirement already satisfied: arrow in /usr/local/lib/python3.11/site-packages (1.2.3)
Requirement already satisfied: python-dateutil>=2.7.0 in /usr/local/lib/python3.11/site-packages (from arrow) (2.8.2)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/site-packages (from python-dateutil>=2.7.0->arrow) (1.9.0)
DEPRECATION: python-datetime-tz 0.5.4 has a non-standard dependency specifier pytz>=2011g. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of python-datetime-tz or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063

Thanks for looking into this.

System Info

jadchaar commented 10 months ago

Hi @tammyalexandra I am unable to reproduce this issue on Python 3.11:

➜  Downloads . env/bin/activate
(env) ➜  Downloads pip install -U arrow
Collecting arrow
  Downloading arrow-1.2.3-py3-none-any.whl (66 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.4/66.4 kB 2.5 MB/s eta 0:00:00
Collecting python-dateutil>=2.7.0 (from arrow)
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting six>=1.5 (from python-dateutil>=2.7.0->arrow)
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, python-dateutil, arrow
Successfully installed arrow-1.2.3 python-dateutil-2.8.2 six-1.16.0
(env) ➜  Downloads python3 --version
Python 3.11.5
(env) ➜  Downloads python3
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> arrow.get("2023-12-01")
<Arrow [2023-12-01T00:00:00+00:00]>
command-tab commented 9 months ago

Success here as well, under Python 3.11 and macOS 14.0:

$ python --version
Python 3.11.3

$ pip install -U arrow
Collecting arrow
  Downloading arrow-1.2.3-py3-none-any.whl (66 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.4/66.4 kB 2.0 MB/s eta 0:00:00
Collecting python-dateutil>=2.7.0 (from arrow)
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 5.6 MB/s eta 0:00:00
Collecting six>=1.5 (from python-dateutil>=2.7.0->arrow)
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, python-dateutil, arrow
Successfully installed arrow-1.2.3 python-dateutil-2.8.2 six-1.16.0

$ python
Python 3.11.3 (main, Jun 21 2023, 19:47:27) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> arrow.get("2023-12-01")
<Arrow [2023-12-01T00:00:00+00:00]>
>>> 
jadchaar commented 9 months ago

Closing since this cannot be reproduced.