Fixing PyInstaller on Mac Yosemite

I tried to install pyinstaller using PIP:

<code>$ pip install pyinstaller </code>

and this installed PyInstaller version 2.1, as you can check using

<code>$ pyinstaller –version</code>

When I tried PyInstaller to one of my python script, it gives me an error. I run PyInstaller in this way:

<code>$ pyinstaller minesweeper.py</code>

Then I got the following error:

<code> struct.error: argument for ‘s’ must be a string</code>

The error is caused from a file

<code>/User/lib/python2.7/site-packages/PyInstaller/loader/pyi_carchive.py</code>

from line 84 and 367. To solve this, I replaced the following lines:

Line 84

<code> rslt.append(struct.pack(self.ENTRYSTRUCT + repr(nmlen) + ‘s’, nmlen + entrylen, dpos, dlen, ulen, flag, typcd, nm + pad))</code>

with the following:

<code> 84: rslt.append(struct.pack(self.ENTRYSTRUCT + repr(nmlen) + ‘s’, nmlen + entrylen, dpos, dlen, ulen, flag, typcd, nm.encode(‘utf8’) + pad)) </code>

and Line 367

<code>cookie = struct.pack(self._cookie_format, self.MAGIC, totallen, tocpos, self.toclen, pyvers, self._pylib_name)</code>

with the following:

<code>cookie = struct.pack(self._cookie_format, self.MAGIC, totallen, tocpos, self.toclen, pyvers, self._pylib_name.encode(‘utf8’)) </code>

After that, my pyinstaller works.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: