Pyinstaller failing on OSX Catalina: cannot find pyconfig.h

Viewed 444

Catalina finally seems to abandon python2.7; and add support to python3; which is a great news.

The not so great news is that Apple decided to make a "customized" version of python3, installed with the Xcode dev tools. The downside of this is that using Pyinstaller to build an executable on Catalina, result in an error, because Pyinstaller cannot find pyconfig.h

This file is included in the python3-dev package, which does not seem to exist on the python3 version installed by OSX dev tools. I tried to run pip3 install python3-dev and that would return an error, saying that there is no such package. I was able to find python-dev, but even installing this package, which I assume is the python2 version of it, does not solve the build problem in pyinstaller.

How do you use pyinstaller on Catalina? The only suggestion I was given is to use brew and install python3 from there, which at this point is quite a hard task, considering I already have python3 installed by the dev tools, and there is no way I can find, to remove it completely.

2 Answers

@rataplan - I faced the same issue recently. I have reinstalled by Xcode and python3 by looking into the below youtube video:

https://www.youtube.com/watch?v=0rg6nyanX5Y&t=635s

Install pyinstaller using pip.

Generate the exec application: python -m PyInstaller yourfilename.py

You can fix this issue by just creating a symbolic link to the include path.

ln -s /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Headers /Library/Python/3.8/include

PyInstaller is trying to find the include path here:

/Library/Python/3.8/include

But the python3 provided by Xcode uses custom paths and the good news is that the include path is just located here:

/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Headers
Related