MacOS运行pip2报错"No module named typing"解决方法

 % pip2
Traceback (most recent call last):
  File "/usr/local/bin/pip2", line 11, in <module>
    load_entry_point('pip==21.1.3', 'console_scripts', 'pip2')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Python/2.7/site-packages/pip-21.1.3-py2.7.egg/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named typing

解决方案:

1.卸载pip2:

python2 -m pip uninstall pip

2.安装pip2:

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py

 sudo python2 get-pip.py

3.查看pip2:

pip2
posted @ 2021-08-04 10:48  M4ny1u  阅读(353)  评论(0编辑  收藏  举报

Email: imanyiu12@foxmail.com