apple@bobo src % pip3 install docxtpl
Collecting docxtpl
Using cached docxtpl-0.18.0-py2.py3-none-any.whl.metadata (8.9 kB)
Requirement already satisfied: python-docx>=1.1.1 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from docxtpl) (1.1.2)
Collecting docxcompose (from docxtpl)
Using cached docxcompose-1.4.0.tar.gz (20 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 14, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/extension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 16, in <module>
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
尝试更新 pip 和 setuptools 到最新版本,这有时可以解决兼容性问题。
pip3 install --upgrade pip setuptools
pip3 install docxtpl