我尝试通过pip安装openpyxl,出现以下错误。我该如何解决。
C:\Users\User>python -m pip install --user openpyxl==3.0.3
Collecting openpyxl==3.0.3
Using cached openpyxl-3.0.3.tar.gz (172 kB)
ERROR: Command errored out with exit status 1:
command: 'C:\Program Files\Python36\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-4ji7fq22\\openpyxl\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-4ji7fq22\\openpyxl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\User\AppData\Local\Temp\pip-install-4ji7fq22\openpyxl\pip-egg-info'
cwd: C:\Users\User\AppData\Local\Temp\pip-install-4ji7fq22\openpyxl\
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\setuptools\extension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\setuptools\dist.py", line 16, in <module>
import pkg_resources
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
看来此回溯的重要部分是:
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
使用this question,尝试:
python3 -m ensurepip --upgrade