编译源程序时,提示: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 Files\Notepad++\456.docx

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

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

最新文章

  1. session实现购物车
  2. 超全面的.NET GDI+图形图像编程教程
  3. Net accounts命令
  4. Codeforces 702C Cellular Network
  5. Python之路【第七篇续】:进程、线程、协程
  6. ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl (转)
  7. POJ 2777 Count Color (线段树成段更新+二进制思维)
  8. IoC和DI的基本概念的思维导图
  9. 应用 memcached 提升站点性能
  10. csp20151203画图 解题报告和易错地方
  11. java 多线程和并行程序设计
  12. IntelliJ IDEA 下的svn配置及使用的非常详细的图文总结
  13. Microsoft .NET Framework
  14. Java SE HashMap的底层实现
  15. 使用 Application Loader提交IPA文件到苹果市场
  16. go语言之进阶篇数组越界导致panic
  17. 转: javascript动态添加、修改、删除对象的属性和方法
  18. 平时收集的一些有关UED的团队和个人博客(转)
  19. python 杂谈
  20. HDU 1007 Quoit Design(经典最近点对问题)

热门文章

  1. 我终于看懂了HBase,太不容易了...
  2. 数据库之 MySQL --- 数据处理 之 表的约束与分页(七)
  3. Java实现 蓝桥杯VIP 算法训练 蜜蜂飞舞
  4. Java实现蓝桥杯墓地雕塑
  5. Java实现 LeetCode 36 有效的数独
  6. Android如何使用SharedPreferences轻量级储存
  7. Android中数据缓存的处理
  8. Jmeter(八) - 从入门到精通 - JMeter配置元件(详解教程)
  9. render props的运用
  10. 代码点(code point)和代码单元(code units)