本人第一安装python-docx很不幸就出现了,如下的错误:(如果你也遇到同样的错误,不要慌可以参考下面解决方案,由于第一次处理这种错误,如有不对欢迎大家多多批评指正

error: can't copy 'docx\templates\default-docx-template': doesn't exist or not a regular file    ---------------  Failed building wheel for python-docx; python-docx的安装使用;python操作word

问题所在是因为我们的setuptools版本太低了

解决办法:

1.首先进行升级

pip install -U setuptools

error: can't copy 'docx\templates\default-docx-template': doesn't exist or not a regular file    ---------------  Failed building wheel for python-docx; python-docx的安装使用;python操作word

2.切换到扩展库的安装目录执行以下命令       pip install python-docx

error: can't copy 'docx\templates\default-docx-template': doesn't exist or not a regular file    ---------------  Failed building wheel for python-docx; python-docx的安装使用;python操作word

error: can't copy 'docx\templates\default-docx-template': doesn't exist or not a regular file    ---------------  Failed building wheel for python-docx; python-docx的安装使用;python操作word

3.验证

# ecoding=utf-8
from docx import Document

document = Document('D:\\11.docx')  #打开文件demo.docx
for paragraph in document.paragraphs:
    print(paragraph.text)  #打印各段落内容文本

document.add_paragraph(
    'Add new paragraph', style='ListNumber'
)    #添加新段落

document.save('demo.docx') #保存文档

error: can't copy 'docx\templates\default-docx-template': doesn't exist or not a regular file    ---------------  Failed building wheel for python-docx; python-docx的安装使用;python操作word

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-17
  • 2021-11-28
  • 2022-01-06
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案