# Getting pyinstaller 3.4 to work with Python 3.7

Python is an excellent language, but given that it’s free, it also comes with a lot of conspicuous loose-ends that you will not expect in commercially supported platforms like MATLAB.

Don’t expect everything to work right out of the box in Python. Everything is like 98% there, with the last 2% frustrate the heck out of you when you are rushing to get from point A to point B and you have to iron out a few dozen kinks before you can really start working.

When I tried use pyinstaller (v3.4) to compile my Python (v3.7) program into an executable, I ended up having to jump through a bunch of hoops:

• pip install pyinstaller gives:
ModuleNotFoundError: No module named 'cffi'
• Then I looked up and installed cffi
pip install cffi
• After the dependency was addressed manually (it shouldn’t )  pip install pyinstaller worked
• Then I tried to compile my first Python executable with pyinstaller, and I got this exception:
File "C:\Python37\lib\site-packages\win32ctypes\core\cffi\_advapi32.py", line 198

^
SyntaxError: invalid syntax
• I searched the exact string and learned that pyinstaller (v3.4) is not ready for Python 3.7 yet! How come pip installer didn’t check for it? I opened up the offending file and looked for line 198 and saw this:
c_creds.CredentialBlobSize = \

ffi.sizeof(blob_data) - ffi.sizeof('wchar_t')

It’s a freaking line continuation character \ (actually the extraneous CR before CRLF) that rooster-blocked it.

• I just deleted the line continuation and merged the two lines, and saved _advapi32.py, then I was able to compile my Python v3.7 code (using pyinstaller 3.4) with no issues.

This is not something you’ll experience as a MATLAB user. The same company, TMW, wrote the MATLAB compiler as well as the rest. The toolbox/packages are released together in one piece so breaking changes that causes failure for the most obvious use case are caught before they get out of the door.

Another example of breaking changes that I ran into: ipdb does not allow you to move cursor backward.

Again, this is the cost associated with free software and access to the latest updates and new features without waiting for April/October (it’s the MATLAB regular release cycle). If hassle and the extra engineering time far exceed licensing MATLAB licensing costs, MATLAB is a better choice, especially if software is just a chore to get your company from point A to point B, and you are willing to pay big bucks to get there quickly and reliably.

Even with free software on the table, your platform choice is always determined by:

• how much your time is worth wrestling problems
• how much flexibility do you need (for customizing to your needs)
• how much you are willing to pay for the licenses and support

In any case, the community did good work. Please consider sponsoring PyInstaller and PSF if you profit immensely from their work.

1,417 total views,  1 views today

Subscribe
Notify of