PyInstaller on 32-bit Linux - ImportError: The 'six' package is required

白昼怎懂夜的黑 提交于 2019-12-03 16:39:42

Well, adding 'six' into hidden packages, as Clement suggested, didn't work, but started a sequence of trial-and-error that finally led to a solution. After the test with "hiddenimports" didn't work I tried just importing 'six' into my Python code. And the compiled executable no longer showed this error! However, it now said that the package named 'packaging' is required... Which I didn't have installed.

To put it short, starting from the initial problem, I did this:

  1. Installed 'packaging' using 'pip':

    sudo pip install packaging

  2. Added these imports into my main Python code:

    import six

    import packaging

    import packaging.version

    import packaging.specifiers

(all the imports added were trial-and-error, done until the PyInstaller-made executable finally worked).

Seems a bit hack-y, as making the executable for a 64-bit Linux didn't require any of these imports, but at least it now works, and the executable size is basically unaffected.

For the following setup (anaconda):

PyInstaller: 3.2
Python: 3.5.2
Platform: Windows-10-10.0.10240-SP0
Numpy: 1.11.1

And the following mwe.py:

import numpy
print ("hello world")

I had to do the following to fix:

pip install packaging

Build with the following bat file (^ is the BAT line continuation):

pyinstaller --noconfirm ^
        --hidden-import six ^
        --hidden-import packaging ^
        --hidden-import packaging.version ^
        --hidden-import packaging.specifiers ^
        --hidden-import packaging.requirements ^
        mwe.py

I had a similar problem. Try to add "six" as well as "kivy" to the hidden_packages in your spec file. If it doesn't work, make sure that setuptools is installed in its 19.2 version. It seemed to be the problem for me on Windows. Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!