我在这里找不到解决方案,所以我会张贴我在这里找到的bug和解决方案,以及帮助我的链接。
问题是:当我导入docx时
import docx
我收到窃听器了:
import docx
Traceback (most recent call last):
File "<ipython-input-3-326e089686b3>", line 1, in <module>
import docx
File "C:\Users\T722696\AppData\Roaming\Python\Python37\site-packages\docx.py", line 30, in <module>
from exceptions import PendingDeprecationWarning
ModuleNotFoundError: No module named 'exceptions'
发布于 2019-10-01 14:28:51
我找到了这个解决方案here,但它没有标记为解决方案。因此,我将其标记为解决方案,并将其正确地归功于@Dmtry和do @dsh,因为docx与Python3.7“还不兼容”,解决方案是在使用Python3.7时更改docx本身:
一步步地:
1)打开docx.py
2)你会发现:
row | code
25 | try:
26 | from PIL.ExifTags import TAGS
27 | except ImportError:
28 | TAGS = {}
29 |
30 | from exceptions import PendingDeprecationWarning
3)必须删除第30行并插入以下内容:
try:
from exceptions import PendingDeprecationWarning
except ImportError:
pass
4)这应该能解决你的问题。
https://stackoverflow.com/questions/58186869
复制相似问题