7

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 !

Solenne Daguerre
  • 119
  • 1
  • 2
  • 8

4 Answers4

8

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

oori
  • 5,533
  • 1
  • 30
  • 37
oetzi
  • 1,002
  • 10
  • 21
5

I found solution from here.

  1. In my case, I open hook-pkg_resources.py file from the following directory:

    ~/.local/lib/python3.6/site-packages/PyInstaller/hooks/
    
  2. After that I added this line of code:

    hiddenimports.append('pkg_resources.py2_warn')
    

    between these two lines of code:

    hiddenimports = collect_submodules('pkg_resources._vendor')
    

    and

    excludedimports = ['__main__']
    
  3. After that, I ran PyInstaller again and the resulted executable worked like charm.

RobC
  • 22,977
  • 20
  • 73
  • 80
Wild Teddy
  • 334
  • 8
  • 7
2

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

Brian Burton
  • 3,648
  • 16
  • 29
2

Stumbled uppon this answer first on google when searching for this error code, so for future reference ill just leave a link to this issue that solved my problem:

https://stackoverflow.com/a/59979390/10565375

tldr:

pyinstaller --hidden-import=pkg_resources.py2_warn example.py
kruserr
  • 463
  • 4
  • 8