[英]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.