Today I want to build a python script to EXE file using PyInstaller. But after running PyInstaller, I got following error
No module named pefile
The full stack trace is
Traceback (most recent call last): File "D:\\PyInstaller\\pyinstaller.py", line 14, in <module> from PyInstaller.__main__ import run File "D:\PyInstaller\PyInstaller\__main__.py", line 21, in <module> import PyInstaller.building.build_main File "D:\PyInstaller\PyInstaller\building\build_main.py", line 34, in <module> from .api import PYZ, EXE, COLLECT, MERGE File "D:\PyInstaller\PyInstaller\building\api.py", line 38, in <module> from PyInstaller.utils.win32 import winmanifest, icon, versioninfo, winresource File "D:\PyInstaller\PyInstaller\utils\win32\versioninfo.py", line 17, in <module> import pefile ImportError: No module named pefile
Starting from PyInstaller 3.2, a new module named pefile is introduced. This module is used to work with Windows binary file (EXE file, also called PE file). Before PyInstaller 3.2, PE related operation is done using its own module, like setting PE header and DOS header)
Solution
Assume the Python installation direcotry is C:\Python27.
Open Command Prompt window, and navigate to C:\Python27\Scripts
cd C:\Python27\Scripts
Then install pefile module using following command
pip install pefile
(pip is built into latest Python distribution, 2.7.12 for now)
The post No module named pefile appeared first on Redino blog.