Python Error : No module named pkg_resources

Solenne Daguerre picture Solenne Daguerre · Nov 25, 2019 · Viewed 16.8k times · Source

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 !

Answer

oetzi picture oetzi · Feb 4, 2020

pyinstaller 3.6 is incompatible with setuptools 45.1.0 on python 3.7.*, should be downgraded to 45.0.0

pip install setuptools==45.0.0

can also be fixed with passing/adding hidden_imports 'pkg_resources.py2_warn' to pyinstaller spec

Issue and solutions are tracked here: https://github.com/pypa/setuptools/issues/1963