Python 错误:没有名为 pkg_resources 的模块

问题描述:

我想在 MacOS 上使用 Python3.7

I would like to use Python3.7 on MacOS

我已经有了 Python 2.7 版本.

I already Python 2.7 version.

我在 .bash_profile 上创建了一个别名,alias python="/usr/local/bin/python3.7" 然后 source ~/.bash_profile代码>.

I created an alias on .bash_profile, alias python="/usr/local/bin/python3.7" then source ~/.bash_profile.

所以我把 Python2.7 删除到 /usr/local/lib/

So I deleted Python2.7 to /usr/local/lib/

现在,当我尝试执行 pip install PySide2 时,出现错误:

Now, when I try to execute pip install PySide2, I have an error :

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

我认为自从我删除 Python2.7 后就发生了这个错误

I think this error has happened since I deleted Python2.7

有人可以帮助我解决我的错误吗?

Someone can help me to resolve my error ?

谢谢!

这是由于setuptools包损坏引起的,您只需重新安装即可.

This is caused because of a broken setuptools package, you just need to reinstall it.

对于大多数操作系统:pip install setuptools

Linux:apt-get install python-setuptoolsyum install python-setuptools