当我尝试通过cmd行安装软件包时,使用Python遇到以下错误。它运行已经好几个月了,这是我第一次感到头疼,
以前有人撞过吗?
C:\>python -m pip install numpy
Traceback (most recent call last):
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\__main__.py", line 16, in <module>
from pip._internal.main import main as _main # isort:skip # noqa
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\main.py", line 13, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\cli\autocompletion.py", line 11, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 25, in <module>
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\locations.py", line 18, in <module>
from pip._internal.utils import appdirs
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\utils\appdirs.py", line 16, in <module>
from pip._internal.utils.compat import WINDOWS, expanduser
File "C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip\_internal\utils\compat.py", line 17, in <module>
from pip._vendor.urllib3.util import IS_PYOPENSSL
ModuleNotFoundError: No module named 'pip._vendor.urllib3'
答案 0 :(得分:0)
来自github的解决方案: https://github.com/pypa/pip/issues/6261#issuecomment-465067873
rm -rf /usr/lib/python3.7/site-packages
python3.7 -m ensurepip
pip install --upgrade pip
就您而言,删除
C:\Users\agryga\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip
然后运行
python3.7 -m ensurepip
pip install --upgrade pip