Python Forum
.py to exe error "oserror winerror 193" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: .py to exe error "oserror winerror 193" (/thread-22852.html)



.py to exe error "oserror winerror 193" - michael1789 - Nov-29-2019

My search show that this is a common error when trying pyinstaller.

Error:
oserror winerror 193 1 is not a valid win32 application
Something about conflicting versions of Python... I think. I'm not sure if it my editor "Thonny" that is the problem, or my Python3, or my windows OS.

Is it that my windows is 32 bit, and my python3 is the 64 bit version? or visa versa? I don't really even know what that means so I wanted to check if anyone here doesn't before I start uninstalling and reinstalling stuff (incorrectly).


RE: .py to exe error "oserror winerror 193" - snippsat - Nov-30-2019

Look as this Thread it can help.
You need to figure out what's the main version in Environment Variables Path.
Thonny comes with own build in Python version for ease of use,but you can also use python.org version.

Do this from command line(cmd)
# Test python
C:\>python -c "import sys; print(sys.executable)"
C:\python37\python.exe

# Test pip
C:\>pip -V
pip 19.3.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Where is pyinstaller
C:\>where pyinstaller
C:\Python37\Scripts\pyinstaller.exe
C:\Python38\Scripts\pyinstaller.exe

C:\>
So my main version is Windows Path is Python 3.7,so if i do this.
C:\>pyinstaller --onefile some.py
It will use Python 3.7,this is same all folder in cmd as it's main version in Path.
If i go into C:\Python38\Scripts\ folder and do the same it will pyinstaller(not work yet 3.8) with Python 3.8.

Can have may version i have lot,just need to understand how Windows see this and have one main version.
py can be used to assess all standard versions version.
E:\div_code
λ py -0
Installed Pythons found by py Launcher for Windows
 -3.8-32 *
 -3.7-32
 -3.6-32
 -3.5-32
 -3.4-32
 -2.7-32
Quote:Is it that my windows is 32 bit, and my python3 is the 64 bit version?
If you start python from command line(cmd) you will see if Python version is 32-bit or 64-bit.
[MSC v.1916 32 bit (Intel)] --> 32-bit 
[MSC v.1915 64 bit (AMD64)] --> 64-bit



RE: .py to exe error "oserror winerror 193" - michael1789 - Dec-02-2019

My progress:

I didn't have pip installed correctly, now I do.
My windows 10 in 64 bit
My python3.7.2 is 64 bit



Thonny is running a "bundled" python that is 32 bit. I changed the internal to run the same version as the one in my path. Pyinstaller gets same error.

From Idle my game gets pygame error.
Error:
Traceback (most recent call last): File "C:\Users\owner\Desktop\Python3\Space_Shooter\Main.py", line 1, in <module> import pygame File "C:\Users\owner\AppData\Roaming\Python\Python37\site-packages\pygame\__init__.py", line 136, in <module> from pygame.base import * ModuleNotFoundError: No module named 'pygame.base'
Already had done:
C:\Users\owner\AppData\Local\Programs\Python\Python37>pip install pygame
Requirement already satisfied: pygame in c:\users\owner\appdata\roaming\python\python37\site-packages (1.9.4)


I'm going to have to write something that takes no imports and see if it converts to .exe.


RE: .py to exe error "oserror winerror 193" - michael1789 - Dec-03-2019

So... I uninstalled python and pycharm and thonny. Then I reinstalled python3.7.2 (64bit), pip, pygame, and pyinstaller.

My programs run in IDLE, but I get the exact error from pyinstaller about a 32 bit application... of which I'm not using one.

I'd really like to be able to send things to people. Is there something more I can try? Is there an alternate method to convert .py to exe?