Python-docx: Warning: Using or importing ABCs from collections is deprecated

Created on 20 Feb 2019  路  10Comments  路  Source: python-openxml/python-docx

I recently encountered the following warning while running python-docx:

section.py:7: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Sequence

I noticed that other third-party packages have encountered this same issue and resolved it. See https://github.com/marshmallow-code/marshmallow/issues/1027 for example.

shortlist

Most helpful comment

Hmm, quite right, apologies for that. I'll get that fixed up this weekend and drop a new release.

All 10 comments

The environment that I ran under was a Mac High Sierra with Python 3.7.2 configured.

Ah, right, I've seen this before elsewhere. Thanks for reporting this. I'll get this fixed up for the next release.

This issue is still present in v0.8.10.

Hmm, shouldn't be, you can see the fix here in the code tree:
https://github.com/python-openxml/python-docx/blob/master/docx/compat.py

What's the full stack-trace you're getting?

Erm, it's to do with docx/section.py

env/lib/python3.7/site-packages/docx/section.py:7
  /Users/techouse/Work/projectname/env/lib/python3.7/site-packages/docx/section.py:7: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Sequence

The docx/section.py I got from PyPI, looks like this for some reason and the problem is on line 7. The v0.8.10 docx/section.py on GitHub does not have that problematic import.

This is the docx/section.py from PyPI

# encoding: utf-8

"""The |Section| object and related proxy classes"""

from __future__ import absolute_import, division, print_function, unicode_literals

from collections import Sequence  # <-- the problematic import on line 7

from docx.blkcntnr import BlockItemContainer
from docx.enum.section import WD_HEADER_FOOTER
from docx.shared import lazyproperty


class Sections(Sequence):
    """Sequence of |Section| objects corresponding to the sections in the document.

    ### REST OF THE FILE ###

I just checked and you fixed it in a commit on June 11, 2019, however PyPI has version v0.8.10 from January 9, 2019. So I'm guessing a package deployment error somewhere?

Hmm, quite right, apologies for that. I'll get that fixed up this weekend and drop a new release.

Hi @scanny , I found the same issue :
=============================== warnings summary ===============================
/Users/kumar.shishir/PycharmProjects/python_api_automation/venv/lib/python3.7/site-packages/jinja2/runtime.py:318
/Users/kumar.shishir/PycharmProjects/python_api_automation/venv/lib/python3.7/site-packages/jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping

-- Docs: https://docs.pytest.org/en/latest/warnings.html
Python 3.7
MacOS Mojave version 10.14.6
May I know there had been a fix for the issue and released.

0.8.10

DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
    from collections import Sequence

This still seems to be a problem with the latest version 0.8.10.

I confirm that.

@scanny would you mind to reopen this issue, or should I send any more details?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JiyhonLiu picture JiyhonLiu  路  3Comments

Tores76 picture Tores76  路  6Comments

bendaojiu picture bendaojiu  路  5Comments

avvRobertoAlma picture avvRobertoAlma  路  7Comments

achillis1 picture achillis1  路  5Comments