Search code examples
pythonpython-3.xpython-2.7pippyside2

Python Error : No module named pkg_resources


I would like to use Python3.7 on MacOS

I already Python 2.7 version.

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

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

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

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

Someone can help me to resolve my error ?

Thank you !


Solution

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

    For most operating systems: pip install setuptools

    Linux: apt-get install python-setuptools or yum install python-setuptools