0

I have a written a piece of code in python and everything works fine when I run it in Pycharm. So I tried to create an executable file from my code using pyinstaller. the .exe file is being created however when I run the .exe file, an error pops up:

wand module not found.

In my code, I convert a PDF into an image using 'wand' library, here is the code:

from wand.image import Image as wi

pdf_image = wi(filename=pdf, resolution=300)

and that's basically the only line that I use 'wand' in my code. Anyone knows how can i solve this issue or any other workaround that I don't use wand and convert my pdf into image with some other library?

zabop
  • 6,750
  • 3
  • 39
  • 84
  • What are you using to create the executable file? – Swetank Poddar Apr 13 '20 at 12:39
  • I am using pyinstaller – davoud malekian Apr 13 '20 at 12:42
  • Parsing a pdf file is nontrivial. There is no easy way to do it without a library. You could perhaps do it through some system calls. Why wouldn't you want to use the module that you are in fact using? – John Coleman Apr 13 '20 at 14:12
  • I don't have any problem with using 'wand', the thing is I can't create an executable file because it gives me the error that I just described. I really don't know how to do the system call that you just mentioned, can you please explain more. thanks. – davoud malekian Apr 13 '20 at 14:19
  • PyInstaller's killer feature (IMHO) is it's hooks. It doesn't work with every library, so how do you fix that? You write a hook, which adapts PyInstaller to the needs of that package. See the PyInstaller docs "Understanding PyInstaller hooks" for more details. – Legorooj Apr 14 '20 at 12:34
  • Wand dynamically links with shared ImageMagick libraries installed on the system. PyInstaller doesn't package OS systems. If you just want an image of PDF, call `gs` utility with subprocess. – emcconville Apr 14 '20 at 21:31

1 Answers1

0

I don't know what is the actual solution for this issue but when I removed wand and installed it again using pip install wand, I was able to create the executable file that I wanted.