python - 无法安装 python-docx (MacOS)
问题描述
我正在尝试安装docx
软件包。但得到以下信息ImportError
:
ImportError: cannot import name Document
所以按照这里的建议,我尝试了:
pip install python-docx
但出现以下错误(python 版本:2.7.15)
..
..
..
creating build/lib/docx/templates
copying docx/templates/default-header.xml -> build/lib/docx/templates
copying docx/templates/default-settings.xml -> build/lib/docx/templates
copying docx/templates/default-footer.xml -> build/lib/docx/templates
error: can't copy 'docx/templates/default-docx-template': doesn't exist or not a regular file
Command
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import
setuptools,tokenize;__file__='/private/var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-build-ks26RP/python-docx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-1SQvtb-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-build-ks26RP/python-docx/
解决方案
python-docx
在最近发布的 v0.8.9 中,在某些环境中安装时出现问题。对于大多数用户来说,安装 v0.8.10 应该可以解决这个问题。如果安装仍然失败(在某些 Linux 版本上),更新 setuptools 已报告修复它:
$ pip install -U setuptools
推荐阅读
- traefik - 缺少尾随“/”时无法访问 Portainer。是否可以获得与 Nginx proxy_pass 相同的行为?
- python - 如何逐行比较两个数据框?
- java - 如何使用 xpath 相对于通过 innerText 标识的另一个元素定位一个元素
- sql-server - 合并 200 个大型(50mb 到 500mb)CSV 文件的最快方法是什么?
- java - 如何进行枚举聚合?
- python - 如何使用 Python 2.7 创建一个将文件夹中的最新文件复制到另一个文件夹的函数?
- python - 导出如何在 plotly DataTable 中工作?
- php - 如何从 laravel excel maatwebsite 的子表中调用单元格值?
- google-cloud-platform - 通过 mosquitto 代理发布到谷歌云中的不同 pubsub 主题?
- storage - 查找对 Azure 存储表的删除实体调用