1

Problem statement:

I can't seem to run

'PyInstaller --onefile myfile.py'

on a file containing

import wmi

It cannot find win32api. I get a popup warning saying python has stopped etc. My console says "ImportError: No module named 'win32api'". I can run 'import win32api', 'import win32com', and 'import WMI' in python directly in the same environment without issue. I fundamentally don't understand what is wrong here.

Error message:

3469 INFO: Loading module hook "hook-pywintypes.py"...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: No module named 'win32api'

I have tried:

PyInstaller - ImportError: No module named win32api - 'import os' works fine for PyInstaller and runs fine in python.

No module named 'win32api' - Not very helpful

How to install pywin32 module in windows 7 - This is where I got the SF link (python3.5 amd64 pywin32 version)

ImportError: no module named win32api - I thought it might be a path thing, but my installation appears to be in the correct place: "C:\Users\myuser\AppData\Local\Continuum\Anaconda3\pkgs\pywin32-220-py35_2\Lib\site-packages\win32"

I can run 'PyInstaller --onefile myscript.py' on other files, and have without issue as long as they don't use the wmi module.

I looked at the win32com _init__.py line 5 where it's messing up and it's just an import statement for win32api.

System:

Windows 7 x64, Python 3.5.3 64bit, Anaconda 4.3.14 64bit, using pyinstaller 3.2.3 (recommended by this thread), with pywin32 220 (with sourceforge download [I know, I tried pip, conda, and easy_install]) and I'm running it in cmder as an admin.

J. Doe
  • 11
  • 1
  • 5

2 Answers2

2

In my case, I couldn't use the module in the python shell, even if original one could. When I execute python shell as an administrator option, it was solved. Try it with administrator execution. I used python version 3.5.2 with windows x64bits.

Y.frank
  • 56
  • 4
0

I face this problem but I install ---> pip install pypiwin32 to solve my problems