img2pdf.py “no module named Image”

為{幸葍}努か 提交于 2021-01-29 17:39:21

问题


Hello I am running Python 2.7 64 bit on windows 7. I've found a python script online called img2pdf.py which could be very useful to me but I can't run it. I've installed the Pillow library for win64 (from http://www.lfd.uci.edu/~gohlke/pythonlibs/) and Image.py is present in "C:\Python27\Lib\site-packages\PIL"

I've downloaded the script to a directory containing my image, and python is on my path but when I type

python img2pdf.py myimage.j2k

at the command prompt I get an error that states

Traceback (most recent call last):
  File "img2pdf.py" line 18, in <module>
    import Image
ImportError: No module named Image

What have I missed?


回答1:


On the Pillow library link, it is written:

Note: use from PIL import Image instead of import Image.

But when I look to the img2pdf.py script that I've found here, it is written import Image. So I guess you have to edit your img2pdf.py as specified above.




回答2:


  1. Install Python for Windows, e.g. "python-3.5.0-amd64.exe" --> C:\Python
  2. Extract the zipped archive for img2pdf to C:\Python\Sources\img2pdf
  3. Go to C:\Python\Scripts
  4. Run pip.exe install ..\Sources\img2pdf
  5. The package is now available from command line as "img2pdf.exe" in C:\Python\Scripts


来源:https://stackoverflow.com/questions/18517118/img2pdf-py-no-module-named-image

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