我编写了一个简单的代码,使用ImageMagick将PDF转换为JPG,如下所示
import os
from wand.color import Color
from wand.image import Image
if __name__ == "__main__":
source_file = os.path.join(os.getcwd(), "sample.pdf")
target_file = os.path.join(os.getcwd(), "sample.jpg")
with Image(filename=source_file) as img:
img.alpha_channel = False
img.background_color = Color('white')
img.resize(600, 870)
img.format = 'jpeg'
img.save(filename=target_file)
python应用程序运行,但是当我通过命令pyinstaller extract.py
将其转换为.exe并运行生成的.exe时,我收到以下错误:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
File "C:\Users\Abouzar\pydev\extract\src\build\cover_extract\out00-PYZ.pyz\wand.color", line 9, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
File "C:\Users\Abouzar\pydev\extract\src\build\cover_extract\out00-PYZ.pyz\wand.api", line 1173, in <module>
File "C:\Users\Abouzar\pydev\extract\src\build\cover_extract\out00-PYZ.pyz\ctypes", line 365, in __init__
WindowsError: [Error 126] The specified module could not be found
有什么方法可以解决这个问题吗?