pyinstaller add tag
Pax
I'm trying to package a CLI app as a standalone executable using PyInstaller. I don't have a Linux OS so I used Vagrant to package it, taking the CentOS 7 box since the server where the executable will run is also CentOS 7. 

I was able to create a standalone executable and it ran successfully with a fresh CentOS 7 Vagrant machine (no provisioning script/no python3 and its dependencies installed). But when I run the executable in the server, it gives me this error:

```shell
[user@server ~]$ emails_automation/emails --help
[22874] Error -3 from inflate: unknown compression method
[22874] Error decompressing _asyncio.cpython-38-x86_64-linux-gnu.so
Failed to write all bytes for _asyncio.cpython-38-x86_64-linux-gnu.so
fwrite: Bad address
```

# Observations 

✅ Both VM and actual server has same glibc version:

VM:
```shell
[root@localhost emails] ldd --version
ldd (GNU libc) 2.17
```

Server:
```shell
[user@server ~]$ ldd --version
ldd (GNU libc) 2.17
```

✅ zlib is installed

I searched for "inflate: unknown compression method" in the pyinstaller [repo](https://github.com/pyinstaller/pyinstaller/search?q=inflate%3A+unknown+compression+method) and returned files related to `zlib`



So I checked whether zlib is installed in the server, and the fresh VM (the one where I tested the standalone executable) by running the python REPL and importing zlib. IIUC, if zlib is not installed in the server, it will raise an `ImportError` [[source](https://stackoverflow.com/a/63116320/11006952)]

```
[vagrant@localhost ~]$ python
Python 2.7.5 (default, Apr  2 2020, 13:16:51) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
>>> zlib.crc32
<built-in function crc32>
```

```
[user@server ~]$ python
Python 2.7.5 (default, Nov 16 2020, 22:23:17) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
>>> zlib.crc32
<built-in function crc32>
```

What is causing this error and how do I solve it?
Top Answer
Pax
I resorted to a workaround: I bundled the app to a one-folder instead of a one-file executable.

According to the [docs](https://pyinstaller.readthedocs.io/en/stable/operating-mode.html#bundling-to-one-file),

> The one executable file contains an embedded archive of all the Python modules used by your script, as well as compressed copies of any non-Python support files (e.g. .so files). The **bootloader uncompresses the support files** and writes copies into the the temporary folder. 

Given the "error decompressing" message and confirmation from the docs that this behaviour is unique to the one executable file, I tried bundling the app to a one-folder and it works fine.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.