zoukankan      html  css  js  c++  java
  • docx.opc.exceptions.PackageNotFoundError: Package not found at '文件名.docx' 问题解决

    编译源程序时,提示:docx.opc.exceptions.PackageNotFoundError: Package not found at '文件名.docx' 。

    源文件明明存在啊,难道是用的相对路径不能读取,于是换了绝对路径,结果还是提示此错误。

    tpl = DocxTemplate("123.docx")

    到底是什么原因呢?

    百度了一下,找到如下提示:【原文:https://www.javaear.com/question/47199300.html】

    This error simply means there is no .docx file at the location you specified.

    Since you specified a relative path, the actual path used is determined by adding 'TestDir/dir2/doc22.docx' to the current working directory Python is using at run time.

    You can discover the path being used with this short code snippet:

    import os
    print(os.path.abspath('TestDir/dir2/doc22.docx')
    

    I expect you'll find that it prints out a path that does not exist, and that you'll need to modify the path string you give it to point to the right place.

    Worst case, you can specify an absolute path, like /home/ch_dmitriy/Documents/Projects/Tutorials/TestDir/dir2/doc22.docx.

    根据提示,插入上述代码后再次运行,查看显示的路径,便知道问题出在哪里了

    C:Program FilesNotepad++456.docx

    原来程序编译运行的默认地址是notpad++的安装目录,所以导致找不到文件了。

    于是,在CMD中重新进入源文件目录,编译并运行,结果顺利通过编译。

  • 相关阅读:
    iOS:Core Data 中的简单ORM
    Win8:Snap 实现
    js: 删除node的所有child
    WinJS:Listview item 设置背景透明
    iOS: 消息通信中的Notification&KVO
    win8: 清除iframe的缓存
    What's New in iOS7,iOS7新特性介绍
    "Entity Framework数据插入性能追踪"读后总结
    夜,思考——我想要的到底是什么?
    【查询】—Entity Framework实例详解
  • 原文地址:https://www.cnblogs.com/imustun/p/11225178.html
Copyright © 2011-2022 走看看