当我尝试使用 sudo 安装 python-docx 时sudo pip install python-docx
(甚至不使用 sudo 时),它总是失败。我不确定,但我认为可能是因为缺少模板,因为最后一个错误总是error: can't copy 'docx/templates/default-docx-template': doesn't exist or not a regular file
。
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-T_7KXe/python-docx/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-T_7KXe/python-docx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-3WmEua --python-tag cp27
cwd: /private/tmp/pip-install-T_7KXe/python-docx/
Complete output (107 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/docx
copying docx/package.py -> build/lib/docx
copying docx/compat.py -> build/lib/docx
copying docx/blkcntnr.py -> build/lib/docx
copying docx/__init__.py -> build/lib/docx
copying docx/section.py -> build/lib/docx
copying docx/shared.py -> build/lib/docx
copying docx/api.py -> build/lib/docx
copying docx/document.py -> build/lib/docx
copying docx/settings.py -> build/lib/docx
copying docx/exceptions.py -> build/lib/docx
copying docx/shape.py -> build/lib/docx
copying docx/table.py -> build/lib/docx
creating build/lib/docx/oxml
copying docx/oxml/coreprops.py -> build/lib/docx/oxml
copying docx/oxml/simpletypes.py -> build/lib/docx/oxml
copying docx/oxml/__init__.py -> build/lib/docx/oxml
copying docx/oxml/ns.py -> build/lib/docx/oxml
copying docx/oxml/section.py -> build/lib/docx/oxml
copying docx/oxml/shared.py -> build/lib/docx/oxml
copying docx/oxml/numbering.py -> build/lib/docx/oxml
copying docx/oxml/document.py -> build/lib/docx/oxml
copying docx/oxml/styles.py -> build/lib/docx/oxml
copying docx/oxml/settings.py -> build/lib/docx/oxml
copying docx/oxml/exceptions.py -> build/lib/docx/oxml
copying docx/oxml/shape.py -> build/lib/docx/oxml
copying docx/oxml/table.py -> build/lib/docx/oxml
copying docx/oxml/xmlchemy.py -> build/lib/docx/oxml
creating build/lib/docx/opc
copying docx/opc/package.py -> build/lib/docx/opc
copying docx/opc/coreprops.py -> build/lib/docx/opc
copying docx/opc/compat.py -> build/lib/docx/opc
copying docx/opc/oxml.py -> build/lib/docx/opc
copying docx/opc/constants.py -> build/lib/docx/opc
copying docx/opc/__init__.py -> build/lib/docx/opc
copying docx/opc/spec.py -> build/lib/docx/opc
copying docx/opc/shared.py -> build/lib/docx/opc
copying docx/opc/packuri.py -> build/lib/docx/opc
copying docx/opc/phys_pkg.py -> build/lib/docx/opc
copying docx/opc/exceptions.py -> build/lib/docx/opc
copying docx/opc/pkgreader.py -> build/lib/docx/opc
copying docx/opc/part.py -> build/lib/docx/opc
copying docx/opc/rel.py -> build/lib/docx/opc
copying docx/opc/pkgwriter.py -> build/lib/docx/opc
creating build/lib/docx/dml
copying docx/dml/color.py -> build/lib/docx/dml
copying docx/dml/__init__.py -> build/lib/docx/dml
creating build/lib/docx/enum
copying docx/enum/style.py -> build/lib/docx/enum
copying docx/enum/__init__.py -> build/lib/docx/enum
copying docx/enum/section.py -> build/lib/docx/enum
copying docx/enum/text.py -> build/lib/docx/enum
copying docx/enum/shape.py -> build/lib/docx/enum
copying docx/enum/table.py -> build/lib/docx/enum
copying docx/enum/dml.py -> build/lib/docx/enum
copying docx/enum/base.py -> build/lib/docx/enum
creating build/lib/docx/image
copying docx/image/tiff.py -> build/lib/docx/image
copying docx/image/gif.py -> build/lib/docx/image
copying docx/image/constants.py -> build/lib/docx/image
copying docx/image/jpeg.py -> build/lib/docx/image
copying docx/image/__init__.py -> build/lib/docx/image
copying docx/image/png.py -> build/lib/docx/image
copying docx/image/bmp.py -> build/lib/docx/image
copying docx/image/exceptions.py -> build/lib/docx/image
copying docx/image/helpers.py -> build/lib/docx/image
copying docx/image/image.py -> build/lib/docx/image
creating build/lib/docx/styles
copying docx/styles/style.py -> build/lib/docx/styles
copying docx/styles/latent.py -> build/lib/docx/styles
copying docx/styles/__init__.py -> build/lib/docx/styles
copying docx/styles/styles.py -> build/lib/docx/styles
creating build/lib/docx/parts
copying docx/parts/story.py -> build/lib/docx/parts
copying docx/parts/__init__.py -> build/lib/docx/parts
copying docx/parts/numbering.py -> build/lib/docx/parts
copying docx/parts/hdrftr.py -> build/lib/docx/parts
copying docx/parts/document.py -> build/lib/docx/parts
copying docx/parts/styles.py -> build/lib/docx/parts
copying docx/parts/settings.py -> build/lib/docx/parts
copying docx/parts/image.py -> build/lib/docx/parts
creating build/lib/docx/text
copying docx/text/run.py -> build/lib/docx/text
copying docx/text/__init__.py -> build/lib/docx/text
copying docx/text/font.py -> build/lib/docx/text
copying docx/text/tabstops.py -> build/lib/docx/text
copying docx/text/parfmt.py -> build/lib/docx/text
copying docx/text/paragraph.py -> build/lib/docx/text
creating build/lib/docx/oxml/text
copying docx/oxml/text/run.py -> build/lib/docx/oxml/text
copying docx/oxml/text/__init__.py -> build/lib/docx/oxml/text
copying docx/oxml/text/font.py -> build/lib/docx/oxml/text
copying docx/oxml/text/parfmt.py -> build/lib/docx/oxml/text
copying docx/oxml/text/paragraph.py -> build/lib/docx/oxml/text
creating build/lib/docx/opc/parts
copying docx/opc/parts/coreprops.py -> build/lib/docx/opc/parts
copying docx/opc/parts/__init__.py -> build/lib/docx/opc/parts
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
----------------------------------------
ERROR: Failed building wheel for python-docx
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-T_7KXe/python-docx/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-T_7KXe/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 /private/tmp/pip-record-AIkp8N/install-record.txt --single-version-externally-managed --compile
cwd: /private/tmp/pip-install-T_7KXe/python-docx/
Complete output (107 lines):
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/docx
copying docx/package.py -> build/lib/docx
copying docx/compat.py -> build/lib/docx
copying docx/blkcntnr.py -> build/lib/docx
copying docx/__init__.py -> build/lib/docx
copying docx/section.py -> build/lib/docx
copying docx/shared.py -> build/lib/docx
copying docx/api.py -> build/lib/docx
copying docx/document.py -> build/lib/docx
copying docx/settings.py -> build/lib/docx
copying docx/exceptions.py -> build/lib/docx
copying docx/shape.py -> build/lib/docx
copying docx/table.py -> build/lib/docx
creating build/lib/docx/oxml
copying docx/oxml/coreprops.py -> build/lib/docx/oxml
copying docx/oxml/simpletypes.py -> build/lib/docx/oxml
copying docx/oxml/__init__.py -> build/lib/docx/oxml
copying docx/oxml/ns.py -> build/lib/docx/oxml
copying docx/oxml/section.py -> build/lib/docx/oxml
copying docx/oxml/shared.py -> build/lib/docx/oxml
copying docx/oxml/numbering.py -> build/lib/docx/oxml
copying docx/oxml/document.py -> build/lib/docx/oxml
copying docx/oxml/styles.py -> build/lib/docx/oxml
copying docx/oxml/settings.py -> build/lib/docx/oxml
copying docx/oxml/exceptions.py -> build/lib/docx/oxml
copying docx/oxml/shape.py -> build/lib/docx/oxml
copying docx/oxml/table.py -> build/lib/docx/oxml
copying docx/oxml/xmlchemy.py -> build/lib/docx/oxml
creating build/lib/docx/opc
copying docx/opc/package.py -> build/lib/docx/opc
copying docx/opc/coreprops.py -> build/lib/docx/opc
copying docx/opc/compat.py -> build/lib/docx/opc
copying docx/opc/oxml.py -> build/lib/docx/opc
copying docx/opc/constants.py -> build/lib/docx/opc
copying docx/opc/__init__.py -> build/lib/docx/opc
copying docx/opc/spec.py -> build/lib/docx/opc
copying docx/opc/shared.py -> build/lib/docx/opc
copying docx/opc/packuri.py -> build/lib/docx/opc
copying docx/opc/phys_pkg.py -> build/lib/docx/opc
copying docx/opc/exceptions.py -> build/lib/docx/opc
copying docx/opc/pkgreader.py -> build/lib/docx/opc
copying docx/opc/part.py -> build/lib/docx/opc
copying docx/opc/rel.py -> build/lib/docx/opc
copying docx/opc/pkgwriter.py -> build/lib/docx/opc
creating build/lib/docx/dml
copying docx/dml/color.py -> build/lib/docx/dml
copying docx/dml/__init__.py -> build/lib/docx/dml
creating build/lib/docx/enum
copying docx/enum/style.py -> build/lib/docx/enum
copying docx/enum/__init__.py -> build/lib/docx/enum
copying docx/enum/section.py -> build/lib/docx/enum
copying docx/enum/text.py -> build/lib/docx/enum
copying docx/enum/shape.py -> build/lib/docx/enum
copying docx/enum/table.py -> build/lib/docx/enum
copying docx/enum/dml.py -> build/lib/docx/enum
copying docx/enum/base.py -> build/lib/docx/enum
creating build/lib/docx/image
copying docx/image/tiff.py -> build/lib/docx/image
copying docx/image/gif.py -> build/lib/docx/image
copying docx/image/constants.py -> build/lib/docx/image
copying docx/image/jpeg.py -> build/lib/docx/image
copying docx/image/__init__.py -> build/lib/docx/image
copying docx/image/png.py -> build/lib/docx/image
copying docx/image/bmp.py -> build/lib/docx/image
copying docx/image/exceptions.py -> build/lib/docx/image
copying docx/image/helpers.py -> build/lib/docx/image
copying docx/image/image.py -> build/lib/docx/image
creating build/lib/docx/styles
copying docx/styles/style.py -> build/lib/docx/styles
copying docx/styles/latent.py -> build/lib/docx/styles
copying docx/styles/__init__.py -> build/lib/docx/styles
copying docx/styles/styles.py -> build/lib/docx/styles
creating build/lib/docx/parts
copying docx/parts/story.py -> build/lib/docx/parts
copying docx/parts/__init__.py -> build/lib/docx/parts
copying docx/parts/numbering.py -> build/lib/docx/parts
copying docx/parts/hdrftr.py -> build/lib/docx/parts
copying docx/parts/document.py -> build/lib/docx/parts
copying docx/parts/styles.py -> build/lib/docx/parts
copying docx/parts/settings.py -> build/lib/docx/parts
copying docx/parts/image.py -> build/lib/docx/parts
creating build/lib/docx/text
copying docx/text/run.py -> build/lib/docx/text
copying docx/text/__init__.py -> build/lib/docx/text
copying docx/text/font.py -> build/lib/docx/text
copying docx/text/tabstops.py -> build/lib/docx/text
copying docx/text/parfmt.py -> build/lib/docx/text
copying docx/text/paragraph.py -> build/lib/docx/text
creating build/lib/docx/oxml/text
copying docx/oxml/text/run.py -> build/lib/docx/oxml/text
copying docx/oxml/text/__init__.py -> build/lib/docx/oxml/text
copying docx/oxml/text/font.py -> build/lib/docx/oxml/text
copying docx/oxml/text/parfmt.py -> build/lib/docx/oxml/text
copying docx/oxml/text/paragraph.py -> build/lib/docx/oxml/text
creating build/lib/docx/opc/parts
copying docx/opc/parts/coreprops.py -> build/lib/docx/opc/parts
copying docx/opc/parts/__init__.py -> build/lib/docx/opc/parts
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
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-T_7KXe/python-docx/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-T_7KXe/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 /private/tmp/pip-record-AIkp8N/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
答案1
似乎是源代码的问题,我下载了源代码并删除了文件夹docx/templates/default-docx-template
,然后用它安装了它pip install .
。安装程序似乎只需要文件作为模板...