Porting things to a new PC, and my script/s are broken. New PC is windows 10. Trying to get standalone python working.
API files from v14.2 or thereabouts.
Here's the error after my import attempt:
System error: mgapilib not found!
from mgapilib import *
my_fatal_err('System error: mgapilib not found')
From the interpreter I can see:
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mgapilib import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Presagis\OpenFlight_API\bin\release\mgapilib.py", line 7, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
Just installed the latest API, and that has not solved the issue.
Oops. It seems the error has changed to not being able to locate the module. That seems like a python config issue.
Directory of C:\Presagis\OpenFlight_API\bin\release
08/28/2017 03:27 PM <DIR> .
08/28/2017 03:27 PM <DIR> ..
11/25/2014 11:25 AM 190,464 fltdata.dll
11/25/2014 11:24 AM 2,465,280 mgapilib.dll
11/25/2014 11:31 AM 278,925 mgapilib.py
11/17/2015 03:02 PM 255,669 mgapilib.pyc
11/25/2014 11:22 AM 59,904 mgdd.dll
11/25/2014 11:21 AM 85,504 mgmemory.dll
11/25/2014 11:22 AM 626,176 mgruntime.dll
11/25/2014 11:31 AM 1,005,056 _mgapilib.pyd
8 File(s) 4,966,978 bytes
2 Dir(s) 310,971,428,864 bytes free
C:\Presagis\OpenFlight_API\bin\release>python mgapilib.py Traceback (most recent call last): File "mgapilib.py", line 7, in <module> import _mgapilib ImportError: DLL load failed: %1 is not a valid Win32 application.
It looks like you have a 64 bit version of Python installed but are trying to run the 32 bit version of OpenFlight script. Try changing PRESAGIS_OPENFLIGHT_SCRIPT and PYTHONPATH to point to the folder where the 64 bit binaries of the OFAPI are stored. For v14, those would be located in the bin_x64\release folder (not the bin\release folder which contains 32 bit DLLs)
Let us know if you make any progress.
It does look like things go farther after I changed to the bin.x64 folder. New error though:
There are .pyc and .py versions of this file in the folder specified by PYTHONPATH:
pyc is from 8/29/17 but all other files in here are from 12/11/2016.
First, the pyc file is called the "compiled python file". It is automatically generated by Python when it loads the mgapilib.py file. You can always delete the pyc file and it will come back next time you run. To be safe, go ahead and delete it. If it was generated from a "previous" version of the .py file, you definitely want to get rid of it so a newer (matching) version is generated.
Second, the date mismatch of the files in the bin_x64 folder worries me. It kinda sounds like you have a "Mixed" installation going on. If deleting the pyc file did not help, you might want to try an uninstall/reinstall of the OF API. And if you're using a later version of Creator, it might be a good time to get the API and Creator to match versions.
Let us know your progress.
Re: mixed install - I copied my old API files onto the new PC, but then I installed the correct API version.
The date mismatch makes sense since the pyc is re-created.
Will try a re-install.
OK, uninstalled & removed Suite16\OpenFlight _API folder, then re-installed.
File dates still 12/11/2016.
The system error is an import failure...
Corrected path vars to use Suite16\OpenFlight_API\bin_x64\release
When I import on the python interpreter, something actually executes code:
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from mgapilib import * Type of m_counter: <type 'int'> Label! 0 go: 1 Label! 1 go: 2 etc!
On 32bit API, the import command returns nothing.
So did you get it to work? I would not expect the 32 bit OpenFlight Script to work with a 64 bit version of Python installed. The version of python you want to run (32 or 64 bit) dictates which version of the OpenFlight Script pyd files are required. Note that the pyd file is the "DLL" that links OpenFlight Script to your version of python. It must "match" (32 or 64 bit) Python.
No, it's still not working.
from mgapilib import *
is failing when I run the command:
It also fails on the old PC, which is bizarre.
When I import from the interpreter on the old PC, nothing gets echoed to the screen. On the 64bit PC, stuff is echoed to the screen and then the interpreter exits.
The stuff looks like something related to my code (in terms of content) but I have no idea how mgapilib knows what to run.
rotated 3 ['rotated', ' 174, 242, 9'] rural 3 ['rural', ' 105, 140, 33'] rural2 3 ['rural2', ' 180, 100, 50'] suburb 3 ['suburb', ' 166, 164, 58'] special 3 ['special', ' 249, 7, 7'] urban 4
It's not really the OF API, itself, deciding which one to run, it's Python. When you run Python and try to import "mgapilib" Python looks in PYTHONPATH for the mgapilib module (pyd file). When the pyd file loads, it then looks for the OF API DLLs in PRESAGIS_OPENFLIGHT_SCRIPT. Again the OF API itself is not making any decision on which one to run. You make the decision by setting up your environment properly.
I hope this makes sense.
I understand the environment settings:
Here's the joker:
Where is this variable coming from? I didn't install an API to this location: