odwdinc / Python-SimConnect

Python interface for MSFS2020 SimConnect.dll
GNU Affero General Public License v3.0
270 stars 107 forks source link

Run error for local_example #22

Closed DownInTheShop closed 3 years ago

DownInTheShop commented 3 years ago

New run error for local_example

C:\Python38\python.exe C:/Users/Scott/PycharmProjects/Python-SimConnect/local_example.py
INFO:__main__:START
Traceback (most recent call last):
  File "C:/Users/Scott/PycharmProjects/Python-SimConnect/local_example.py", line 14, in <module>
    sm = SimConnect()
  File "C:\Users\Scott\PycharmProjects\Python-SimConnect\SimConnect\SimConnect.py", line 196, in __init__
    self.dll = SimConnectDll(library_path)
  File "C:\Users\Scott\PycharmProjects\Python-SimConnect\SimConnect\Attributes.py", line 18, in __init__
    self.SimConnect = cdll.LoadLibrary(library_path)
  File "C:\Python38\lib\ctypes\__init__.py", line 447, in LoadLibrary
    return self._dlltype(name)
  File "C:\Python38\lib\ctypes\__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
odwdinc commented 3 years ago

We don't supply the SimConnect.dll in the pip package, The best place is for now is the SDK, You can just place it in the same DIR as your script.

DownInTheShop commented 3 years ago

Ah ok, thanks.

abecor commented 3 years ago

I have this error, too. My pip package came with the SimConnect.dll. I replaced it in the package and placed a copy in the script directory from the SDK and still get this error.

odwdinc commented 3 years ago

@abecor this is an old issue and has be change in the later versions. There is not need to move or replace the dll provide by the pip package. This code is only validated on the dll version provide by the pip package, not to say others will not work. if you have just installed the pip package and are getting this error, more info about your system would be needed.

abecor commented 3 years ago

This is my error with a fresh pip package install:

Traceback (most recent call last):
  File "E:\coding\python\simconnect_test\simconnect_test.py", line 4, in <module>
    sm = SimConnect()
  File "C:\Users\Philipp\AppData\Local\Programs\Python\Python39-32\lib\site-packages\SimConnect\SimConnect.py", line 125, in __init__
    self.dll = SimConnectDll(library_path)
  File "C:\Users\Philipp\AppData\Local\Programs\Python\Python39-32\lib\site-packages\SimConnect\Attributes.py", line 18, in __init__
    self.SimConnect = cdll.LoadLibrary(library_path)
  File "C:\Users\Philipp\AppData\Local\Programs\Python\Python39-32\lib\ctypes\__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\Philipp\AppData\Local\Programs\Python\Python39-32\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 ist keine zulässige Win32-Anwendung

Win10, Python 3.9, MSFS2020

odwdinc commented 3 years ago

@abecor you seem to be running 32bit vs 64bit.

using 32bit Python 3.9.0

PS C:\buld\TestDir> python.exe .\local_example.py
INFO:__main__:START
Traceback (most recent call last):
  File "C:\buld\TestDir\local_example.py", line 14, in <module>
    sm = SimConnect()
  File "C:\Python39-32\lib\site-packages\SimConnect\SimConnect.py", line 125, in __init__
    self.dll = SimConnectDll(library_path)
  File "C:\Python39-32\lib\site-packages\SimConnect\Attributes.py", line 18, in __init__
    self.SimConnect = cdll.LoadLibrary(library_path)
  File "C:\Python39-32\lib\ctypes\__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "C:\Python39-32\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

using 64bit Python 3.9.0, No error:

PS C:\buld\TestDir> python.exe .\local_example.py
INFO:__main__:START
DEBUG:SimConnect.SimConnect:Connected to Flight Simulator!
INFO:SimConnect.SimConnect:SIM OPEN

Hope this helps. all add a note to the Readme

abecor commented 3 years ago

Yes, that did it. Thanks a lot!