简体   繁体   中英

Import error when running pyinstaller app

I have written a Python app which makes use of:

from PIL import Image

I want to distribute a packed version of this application so that whoever uses it does not need to install all the dependencies.

For that I have used pyinstaller , without much success. I run:

pyinstaller --onefile image_download.py

and it does not complain. However, when I run the application, I get:

Traceback (most recent call last): File "", line 26, in File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module exec(bytecode, module. dict ) File "/home/ic/twitter-project/build/image_download/out00-PYZ.pyz/PIL.PngImagePlugin", line 40, in File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module exec(bytecode, module. dict ) File "/home/ic/twitter-project/build/image_download/out00-PYZ.pyz/PIL.Image", line 63, in ImportError: cannot import name _imaging

I am using:

  • Ubuntu 14.04
  • Python 2.7
  • pyinstaller 2.1
  • PIL.VERSION 1.1.7 (although I thought I had installed Pillow 2.8.1)

The script works fine running as python image_download.py , but pyinstaller is not being able to import _imaging, for some reason.

Any suggestions?

Finally I could not use pyinstaller for this, since I could not fix the import problem.

I managed to build a standalone executable with Nuitka and bbfreeze , though, so in case anyone runs into the same problem: it is worth trying other tools.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM