python - 无法安装 python-docx (MacOS)

标签 python macos python-2.7 importerror python-docx

我正在尝试安装 docx 包。但得到以下 ImportError:

ImportError: 无法导入名称文档

所以按照建议here ,我试过了:

pip 安装 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/

最佳答案

最近发布的 v0.8.9 在某些环境中安装 python-docx 时出现问题。安装 v0.8.10 应该可以解决大多数用户的问题。如果安装仍然失败(在某些 Linux 版本上),据报告更新 setuptools 可以修复它:

$ pip install -U setuptools

关于python - 无法安装 python-docx (MacOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54127779/

相关文章:

python - 动态定义一个函数

macos - Mac Developer Program 是否有旧版本的 Mac OS X?

python - 在循环中调用函数两次或更多次

python - 'int' 对象没有属性 '__getitem__'(再次)

python - 使用 Python 将 Pandas 数据框剪切为 shapefile

python - selenium 不能在 url 中使用 &

c++ - 获取dylib模块的SizeOfImage和EntryPoint

macos - iCloud 文档存储中的通知

Python 名称重整与私有(private)继承

python - 对 unicode 字母进行 Pyparsing