odwdinc / Python-SimConnect

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

Error: 'AircraftRequests' object has no attribute 'EnvironmentData' #115

Closed bigsby-exe closed 2 years ago

bigsby-exe commented 2 years ago

Hi All,

New to MSFS but just done a fresh install and trying to connect python and getting the following error. Any ideas on what could cause this?

DEBUG:SimConnect.SimConnect:Connected to Flight Simulator! INFO:SimConnect.SimConnect:SIM OPEN Traceback (most recent call last): File "C:/Users/Bigsby/Desktop/msfs.py", line 6, in <module> aq = AircraftRequests(sm, _time=2000) File "C:\Python310\lib\site-packages\SimConnect\RequestList.py", line 214, in __init__ self.list.append(self.EnvironmentData) AttributeError: 'AircraftRequests' object has no attribute 'EnvironmentData'

bigsby-exe commented 2 years ago

Looks like this issue for me was caused by the latest version, using version 0.4.24 does not have this error.

bigsby-exe commented 2 years ago

For refrence the above error was achieved on Python 3.10, 3.9 & 3.6 with MSFS installed in a custom location and also after a re-install to the default location. It was only fixed when using the older version installed from PyPi

The code to cause the error was as follows:

import logging
from SimConnect import *

logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)

sm = SimConnect()
aq = AircraftRequests(sm, _time=2000)
stevenjoezhang commented 2 years ago

The bug appears to be caused by this commit https://github.com/odwdinc/Python-SimConnect/commit/50cde9f5e8228f7f2c1eea5037ad0c745de545bd#commitcomment-68062056

And a pull request is already opened for it: https://github.com/odwdinc/Python-SimConnect/pull/114

bnepethomas commented 2 years ago

And if you are a bit of a newbie (like me) when it comes to having to grab a earlier release of the package - heres the trick: py -m pip install SimConnect==0.4.24 Very happy to have that available :)

bernbout commented 2 years ago

There is an error in the file RequestList.py found in C:\Users\\AppData\Local\Programs\Python\Python310-32\Lib\site-packages\SimConnect. Edit this file and go down to line 214: self.list.append(self.EnvironmentData) change it to self.list.append(self.AircraftEnvironmentData) Save and now the server will run with no error.

Note: I am using this with FSX hence the 32bit python. Also the Simconnect.dll I replaced with the one from the FSX SDK version which is 32bit.

If anyone wants to use the app (Cockpit Companion) with FSX then simply install 32bit Python, fix the environment to point to this location, replace the simconnect.dll with the 32 bit one and Bob's your uncle.

odwdinc commented 2 years ago

https://github.com/odwdinc/Python-SimConnect/pull/114 merged.