我是一个windows 7用户,使用MS-Office 2016,python 3.6。 最近发现可以用python写word文档,我在 怎么办我安装了docx模块。
pip install docx
但每当我尝试导入docx模块时,我都会得到这个错误。
>>> from docx import Document
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Huzefa\AppData\Local\Programs\Py
in <module>
from exceptions import PendingDeprecationWarn
ModuleNotFoundError: No module named 'exceptions'
我已经尝试过了,但它没有工作。
pip install exceptions
我得到这个错误。
ERROR: Could not find a version that satisfies the requirement exceptions (from versions: none)
ERROR: No matching distribution found for exceptions
我想也许这是因为docx是一个python-2模块,但它不是。我发现 此处
所以谁能告诉我我做错了什么?
我建议你可以尝试这样的 -
$ pip install --pre python-docx
或者你也可以试试sudo命令--------。
$ sudo pip install --pre python-docx
在这之后,尝试 -
from docx import Document
从这里你可以找到[]。https:/python-docx.readthedocs.ioenlatestuserinstall.html][1] 。
尝试使用。
pip install python-docx
对我来说很有效!