Reputation: 26
I'm using Python 3.7 32-bit on Windows 10 64-bit. Python was installed from the executable file on the Python website and NOT Anaconda package. When I run pyinstaller from the command prompt, it returns an error: Error Message I've already installed pypiwin32, pywin32 and win32ctypes. But still have the error.
I tried running pyinstaller from Windows CMD, Pycharm, and a virtual environment, all with the necessary libraries installed, but I'm unable to make it work.
I've googled a lot on this issue but unable to find an answer. Can anyone please help?
Upvotes: 1
Views: 11700
Reputation: 1062
I checked for old Python installation, missing upgrades, the Path environment variable, but at the end I had to run
pip install --upgrade cffi
It fixed the error.
Upvotes: 0
Reputation: 826
There are a lot of versions of this question out there, but, this solution worked for me:
in windows, do 'where pyinstaller' - this will tell you where it appears in the path, and where it will be run from when you type pyinstaller.
I had more than one: an old version in python 3.7 Scripts directory, which appeared first in the path, and the newer one in 3.10 in my AppData directory.
I had been installing and uninstalling and reinstalling the various modules from pip, which applied to the current 3.10 python installation, but the message persisted. Then I tried 'where pyinstaller' and realized the path was picking up the old version in 3.7 first. So, moved 3.7 Scripts to Scripts_bak so the path would no longer pick up pyinstaller from that location, and on the next run of pyinstaller everything worked as expected.
Upvotes: 0
Reputation: 6581
I've read somewhere saying auto-py-to-exe does install a correct version of pywin32-ctypes. So the solution might be: Install the auot-py-to-exe package.
I have not seen the problem. Thus have not verified whether the solution is valid or not.
Having been using auto-py-to-exe for a while. Sometimes it needs other tweaks to get it working for reasons unrelated to the problem in this SO. Since it is based on PyInstaller, installing it should bring in all the correct dependencies for PyInstaller.
Upvotes: 0
Reputation: 161
Open python (tested using Python 3.7.4) and check if the modules can be found from the environment without intervening:
python.exe
>>>import pywintypes
>>>import win32api
If successful, the fix is simple. Find the file compat.py inside the PyInstaller folder. and edit the following two lines.
Replace:
from win32ctypes.pywin32 import pywintypes
from win32ctypes.pywin32 import win32api
with
import pywintypes
import win32api
Upvotes: 10
Reputation: 21
I'm running Python 3.6 on a 32-bit Windows 10 64-bit machine. Using the latest stable version from "pip install pyinstaller" I ran into the same error as you.
The fastest way to fix this is to run the following from cmd:
pip uninstall pyinstaller
Then run the following in cmd:
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
This gives you the version currently in development where they have fixed the issue.
Please see https://media.readthedocs.org/pdf/pyinstaller/latest/pyinstaller.pdf for more information.
Upvotes: 2