when I import docx
I have this error:
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/docx-0.2.4-py3.3.egg/docx.py", line 30, in <module>
from exceptions import PendingDeprecationWarning
ImportError: No module named 'exceptions'
How to fix this error (python3.3
, docx 0.2.4)?
wjandrea
28.5k9 gold badges62 silver badges82 bronze badges
asked Mar 31, 2014 at 15:11
1
If you are using python 3x don’t do pip install docx
instead go for
pip install python-docx
It is compatible with python 3.x
Official Documentation available here: https://pypi.org/project/python-docx/
answered May 29, 2017 at 2:21
ArunArun
3,4401 gold badge11 silver badges19 bronze badges
3
When want to use import docx
, be sure to install python-docx, not docx.You can install the module by running pip install python-docx
.
The installation name docx is for a different module
However,
when you are going to import the python-docx module,
you’ll need to run
import docx
, not import python-docx
.
if still you want to use docx module then:
First of all, you will need to make sure that the docx module is installed.
If not then simply run pip install docx
.
If it shows ‘*requirement already satisfied*’
then the solution is :
- Go to the library to find docx.py file,
you’ll need to go to directory where you installed python then \Lib\site-packages\ and find docx.py file -
Open docx.py file in text editor and find this code
from exceptions import PendingDeprecationWarning
- Replace the above code with
try:
from exceptions import PendingDeprecationWarning
except ImportError:
pass
- Save the file
- Now you can run import docx module in Python 3.x without any problem
answered Jun 13, 2020 at 16:43
Sameer KhanSameer Khan
3413 silver badges4 bronze badges
- Uninstall docx module with
pip uninstall docx
- Download
python_docx-0.8.6-py2.py3-none-any.whl
file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ - Run
pip install python_docx-0.8.6-py2.py3-none-any.whl
to reinstall docx.
This solved the above import error smoothly for me.
wjandrea
28.5k9 gold badges62 silver badges82 bronze badges
answered Mar 4, 2017 at 2:56
VancentVancent
4775 silver badges16 bronze badges
0
If you’re using python 3.x, Make sure you have both python-docx & docx installed.
Installing python-docx :
pip install python-docx
Installing docx :
pip install docx
answered Apr 26, 2020 at 14:20
KalpitKalpit
1711 silver badge5 bronze badges
In Python 3 exceptions module was removed and all standard exceptions were moved to builtin module. Thus meaning that there is no more need to do explicit import of any standard exceptions.
copied from
answered Apr 10, 2018 at 14:39
sajidsajid
8051 gold badge9 silver badges23 bronze badges
pip install python-docx
this worked for me, try installing with admin mode
answered Dec 22, 2021 at 10:53
The problem, as was noted previously in comments, is the docx module was not compatible with Python 3. It was fixed in this pull-request on github: https://github.com/mikemaccana/python-docx/pull/67
Since the exception is now built-in, the solution is to not import it.
docx.py
@@ -27,7 +27,12 @@
except ImportError:
TAGS = {}
-from exceptions import PendingDeprecationWarning
+# Handle PendingDeprecationWarning causing an ImportError if using Python 3
+try:
+ from exceptions import PendingDeprecationWarning
+except ImportError:
+ pass
+
from warnings import warn
import logging
dsh
12k3 gold badges33 silver badges52 bronze badges
answered Aug 24, 2015 at 11:46
0
You need to make it work with python3.
sudo pip3 install python-docx
This installation worked for me in Python3 without any further additions.
python3
>> import docx
PS: Note that the ‘pip install python-docx’ or apt-get python3-docx are not useful.
answered Apr 5, 2020 at 14:15
1
I had the same problem, after installing docx module, got a bunch of errors regarding docx, .oxml and lxml…seems that for my case the package was installed in this folder:
C:\Program Files\Python3.7\Lib\site-packages
and I moved it one step back, to:
C:\Program Files\Python3.7\Lib
and this solved the issue.
Salio
1,06810 silver badges21 bronze badges
answered Jun 27, 2022 at 19:13
python imports exceptions module by itself
comment out import line. it worked for me.
answered Dec 5, 2022 at 18:55
1
when I import docx
I have this error:
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/docx-0.2.4-py3.3.egg/docx.py", line 30, in <module>
from exceptions import PendingDeprecationWarning
ImportError: No module named 'exceptions'
How to fix this error (python3.3
, docx 0.2.4)?
wjandrea
28.5k9 gold badges62 silver badges82 bronze badges
asked Mar 31, 2014 at 15:11
1
If you are using python 3x don’t do pip install docx
instead go for
pip install python-docx
It is compatible with python 3.x
Official Documentation available here: https://pypi.org/project/python-docx/
answered May 29, 2017 at 2:21
ArunArun
3,4401 gold badge11 silver badges19 bronze badges
3
When want to use import docx
, be sure to install python-docx, not docx.You can install the module by running pip install python-docx
.
The installation name docx is for a different module
However,
when you are going to import the python-docx module,
you’ll need to run
import docx
, not import python-docx
.
if still you want to use docx module then:
First of all, you will need to make sure that the docx module is installed.
If not then simply run pip install docx
.
If it shows ‘*requirement already satisfied*’
then the solution is :
- Go to the library to find docx.py file,
you’ll need to go to directory where you installed python then \Lib\site-packages\ and find docx.py file -
Open docx.py file in text editor and find this code
from exceptions import PendingDeprecationWarning
- Replace the above code with
try:
from exceptions import PendingDeprecationWarning
except ImportError:
pass
- Save the file
- Now you can run import docx module in Python 3.x without any problem
answered Jun 13, 2020 at 16:43
Sameer KhanSameer Khan
3413 silver badges4 bronze badges
- Uninstall docx module with
pip uninstall docx
- Download
python_docx-0.8.6-py2.py3-none-any.whl
file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ - Run
pip install python_docx-0.8.6-py2.py3-none-any.whl
to reinstall docx.
This solved the above import error smoothly for me.
wjandrea
28.5k9 gold badges62 silver badges82 bronze badges
answered Mar 4, 2017 at 2:56
VancentVancent
4775 silver badges16 bronze badges
0
If you’re using python 3.x, Make sure you have both python-docx & docx installed.
Installing python-docx :
pip install python-docx
Installing docx :
pip install docx
answered Apr 26, 2020 at 14:20
KalpitKalpit
1711 silver badge5 bronze badges
In Python 3 exceptions module was removed and all standard exceptions were moved to builtin module. Thus meaning that there is no more need to do explicit import of any standard exceptions.
copied from
answered Apr 10, 2018 at 14:39
sajidsajid
8051 gold badge9 silver badges23 bronze badges
pip install python-docx
this worked for me, try installing with admin mode
answered Dec 22, 2021 at 10:53
The problem, as was noted previously in comments, is the docx module was not compatible with Python 3. It was fixed in this pull-request on github: https://github.com/mikemaccana/python-docx/pull/67
Since the exception is now built-in, the solution is to not import it.
docx.py
@@ -27,7 +27,12 @@
except ImportError:
TAGS = {}
-from exceptions import PendingDeprecationWarning
+# Handle PendingDeprecationWarning causing an ImportError if using Python 3
+try:
+ from exceptions import PendingDeprecationWarning
+except ImportError:
+ pass
+
from warnings import warn
import logging
dsh
12k3 gold badges33 silver badges52 bronze badges
answered Aug 24, 2015 at 11:46
0
You need to make it work with python3.
sudo pip3 install python-docx
This installation worked for me in Python3 without any further additions.
python3
>> import docx
PS: Note that the ‘pip install python-docx’ or apt-get python3-docx are not useful.
answered Apr 5, 2020 at 14:15
1
I had the same problem, after installing docx module, got a bunch of errors regarding docx, .oxml and lxml…seems that for my case the package was installed in this folder:
C:\Program Files\Python3.7\Lib\site-packages
and I moved it one step back, to:
C:\Program Files\Python3.7\Lib
and this solved the issue.
Salio
1,06810 silver badges21 bronze badges
answered Jun 27, 2022 at 19:13
python imports exceptions module by itself
comment out import line. it worked for me.
answered Dec 5, 2022 at 18:55
1
Скачиваю библиотеку pip install python-docx
, пытаюсь подключить from docx import Document
как в документации и не видит. У многих была проблема в том, что был установлен старый модуль docx, и всё работало после его удаления, но не у меня.
Что делать? Не нашёл аналогов библиотек для Word документов.
-
Вопрос задан
-
953 просмотра
Мужики я разобрался блин блинский) Вообщем терминал в пайчарме через команду pip устанавливал библиотеки в ооочень глубокую папку отдельную от пайчарма. А в встроенном редакторе библиотек пайчарма, они какие-то не такие и старые (googletrans 3.0 например).
Просто закинул из той папки в папку lib проекта. Вопрос как теперь сразу туда скачивать)
Пригласить эксперта
Если не каких ошибок во время инсталяции не выдало, то скорее всего причина в том что устанавливает он ее в другое окружение. Например я сейчас установил данную библиотеку используяpip
и она работает все нормально. если я запускаю pip show python-docx
из окружения которое использует моя IDE то он мне показывает путь и всю информацию, если же я запущу pip show python-docx
из терминала где окружение другое он выдает что данная библиотека не найдена. То есть у вас проблема в окружении (вы установили библиотеку в одно окружение а импортируете из другого)
-
Показать ещё
Загружается…
21 сент. 2023, в 14:49
25000 руб./за проект
21 сент. 2023, в 14:33
5000 руб./за проект
21 сент. 2023, в 14:16
100000 руб./за проект
Минуточку внимания
когда я импортирую docx
, у меня возникает такая ошибка:
>File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/docx-0.2.4-py3.3.egg/docx.py", line 30, in <module>
from exceptions import PendingDeprecationWarning
ImportError: No module named 'exceptions'
Как исправить эту ошибку (python3.3
, docx 0.2.4
)?
person
user3472559
schedule
31.03.2014
source
источник
Ответы (9)
Если вы используете python 3x, не делайте pip install docx
вместо этого
pip install python-docx
Он совместим с python 3.x
Официальная документация доступна здесь: https://pypi.org/project/python-docx/
person
Arun
schedule
29.05.2017
- Удалите модуль docx с помощью
pip uninstall docx
- Загрузите файл
python_docx-0.8.6-py2.py3-none-any.whl
со страницы http://www.lfd.uci.edu/~gohlke/pythonlibs/ - Запустите
pip install python_docx-0.8.6-py2.py3-none-any.whl
, чтобы переустановить docx. Это без проблем решило указанную выше ошибку импорта. Просто чтобы предложить решение …
person
Vancent
schedule
04.03.2017
Если вы хотите использовать import docx
, обязательно установите python-docx, не docx. Вы можете установить модуль, запустив pip install python-docx
.
Имя установки docx предназначено для другого модуля. Однако
когда вы собираетесь импортировать модуль python-docx, вам нужно будет запустить import docx
, а не import python-docx
.
если вы все еще хотите использовать модуль docx, то:
Прежде всего, вам нужно убедиться, что установлен модуль docx. Если нет, просто запустите pip install docx
. Если он показывает «* требование уже выполнено *», то решение:
- Перейдите в библиотеку, чтобы найти файл docx.py, вам нужно перейти в каталог, в который вы установили python, затем \ Lib \ site-packages \ и найти docx.py файл
-
Откройте файл docx.py в текстовом редакторе и найдите этот код.
from exceptions import PendingDeprecationWarning
- Замените приведенный выше код на
try:
from exceptions import PendingDeprecationWarning
except ImportError:
pass
- Сохраните файл
- Теперь вы можете без проблем запустить модуль import docx в Python 3.x
person
Sameer Khan
schedule
13.06.2020
Если вы используете python 3.x, убедитесь, что у вас установлены как python-docx, так и docx.
Установка python-docx:
pip install python-docx
Установка docx:
pip install docx
person
Kalpit
schedule
26.04.2020
В Python 3 модуль исключений был удален, а все стандартные исключения были перенесены во встроенный модуль. Это означает, что больше нет необходимости делать явный импорт каких-либо стандартных исключений.
скопировано из
person
sajid
schedule
10.04.2018
Проблема, как отмечалось ранее в комментариях, заключается в том, что модуль docx несовместим с Python 3. Это было исправлено в этом запросе на вытягивание на github: https://github.com/mikemaccana/python-docx/pull/67
Поскольку теперь исключение встроено, решение состоит в том, чтобы не импортировать его.
docx.py
@@ -27,7 +27,12 @@
except ImportError:
TAGS = {}
-from exceptions import PendingDeprecationWarning
+# Handle PendingDeprecationWarning causing an ImportError if using Python 3
+try:
+ from exceptions import PendingDeprecationWarning
+except ImportError:
+ pass
+
from warnings import warn
import logging
person
Dmitry
schedule
24.08.2015
У меня была такая же проблема, но pip install python-docx
у меня сработало, я использую python 3.7.1
person
Brighton Chinhongo
schedule
06.11.2019
Вам нужно заставить его работать с python3.
sudo pip3 install python-docx
Эта установка работала для меня на Python3 без каких-либо дополнительных дополнений.
python3
>> import docx
PS: обратите внимание, что pip install python-docx или apt-get python3-docx бесполезны.
person
Shagun
schedule
05.04.2020
@scanny I followed this but did not help. Any idea?
C:\Users\x>pip uninstall docx
Cannot uninstall requirement docx, not installed
C:\Users\x>pip install python-docx
Requirement already satisfied: python-docx in c:\python36\lib\site-packages
Requirement already satisfied: lxml>=2.3.2 in c:\python36\lib\site-packages (from python-docx)
C:\Users\x>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type «help», «copyright», «credits» or «license» for more information.
from docx import Document
Traceback (most recent call last):
File «», line 1, in
File «C:\Python36\lib\site-packages\docx_init_.py», line 3, in
from docx.api import Document # noqa
File «C:\Python36\lib\site-packages\docx\api.py», line 14, in
from docx.package import Package
File «C:\Python36\lib\site-packages\docx\package.py», line 11, in
from docx.opc.package import OpcPackage
File «C:\Python36\lib\site-packages\docx\opc\package.py», line 12, in
from .part import PartFactory
File «C:\Python36\lib\site-packages\docx\opc\part.py», line 12, in
from .oxml import serialize_part_xml
File «C:\Python36\lib\site-packages\docx\opc\oxml.py», line 12, in
from lxml import etree
ImportError: DLL load failed: The specified procedure could not be found.
`