繁体   English   中英

使用 python-docx 时出现错误“找不到参考‘文档’”

[英]Error "Cannot find reference 'Document'" using python-docx

我正在网上关注如何使用 Python 3.9.2 导入 docx 文件的教程。

我已经使用终端安装了以下内容:

python -m pip install --upgrade pip setuptools wheel
pip install python-docx

当我运行 pip 列表时,它显示:

Package     Version
----------- -------
lxml        4.6.2
pip         21.0.1
python-docx 0.8.10
setuptools  54.0.0
wheel       0.36.2

但是,当我输入以下代码时:

from docx import Document
document = Document()
document.save('CV.docx')

我得到这个错误代码:

"Cannot find reference 'Document' in 'docx.py'"

先感谢您!

我不知道为什么,但我关闭了我的终端,重新打开它,以相同的顺序卸载了所有东西,然后重新安装它并且它工作了。

重新安装 python-docx,删除 docx 并安装 python-docx

如果您已经使用推荐安装了 docx,请卸载 docx,

pip uninstall docx

重新安装 Python-docx

pip uninstall python-docx

pip install python-docx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM