Help! I have to resurrect this thread.
I've just uninstalled OpenFlightAPI, then D/L & install OpenFlightAPI windows from here:
https://portal.presagis.com/support/solutions/articles/19000058654-openflight-api-16
It looks like there is some conflict between 32 and 64 bit versions (due to the error message):
C:\Presagis\Suite16\OpenFlight_API\samples>cd scripts C:\Presagis\Suite16\OpenFlight_API\samples\scripts>python egnew1.py Traceback (most recent call last): File "egnew1.py", line 26, in <module> from mgapilib import * File "C:\Presagis\Suite16\OpenFlight_API\bin_x64\release\mgapilib.py", line 7, in <module> import _mgapilib ImportError: DLL load failed: %1 is not a valid Win32 application.
I don't see where my environment is pointing to the wrong library.
PYTHONPATH=C:\Presagis\Suite16\OpenFlight_API\bin_x64\release
Tried the trick of moving out of the folder & re-running the script, same error.
This is Python 2.7.8. BTW I am able to run 'standard' python scripts fine, just nothing
Tried on a different script, it looks like python isn't finding mgapilib, but:
C:\Presagis\Suite16\OpenFlight_API\bin_x64\release>dir /b
fltdata.dll
mgapilib.dll
mgapilib.py
mgapilib.pyc
mgdd.dll
mgmemory.dll
mgruntime.dll
_mgapilib.pyd
There are no files in the current folder *mg* or *dll*.
Thx
This looks exactly like the original problem you had at the top of this thread. You managed to get that working, I suspect you've fallen into the same quagmire again. Review the thread to make sure you have everything set up properly.
At the end of the day, all you have to do for OpenFlight Script to work is set these two environment variables.
PYTHONPATH=C:\Presagis\Suite16\OpenFlight_API\bin_x64\release
PRESAGIS_OPENFLIGHT_SCRIPT=C:\Presagis\Suite16\OpenFlight_API\bin_x64\release
presuming you have installed OpenFlight API 16 x64 and have a 64 bit version of Python installed.
And remember after you install and reset environment variables, you MUST restart any application to pick up the new environment variables. To be safe, it's always best to:
Good luck.
Hm.
Previously I moved my cmd window location. That seems to no longer help.
PC has been rebooted.
Vars:
C:\Users\sallen>set | grep PYTHON
PYTHONPATH=C:\Presagis\Suite16\OpenFlight_API\bin_x64\release
C:\Users\sallen>set | grep OPENF
PRESAGIS_OPENFLIGHT_API=C:\Presagis\Suite16\OpenFlight_API
PRESAGIS_OPENFLIGHT_API_16_0=C:\Presagis\Suite16\OpenFlight_API
PRESAGIS_OPENFLIGHT_API_LAST=C:\Presagis\OpenFlight_API
PRESAGIS_OPENFLIGHT_SCRIPT=C:\Presagis\Suite16\OpenFlight_API\bin_x64\release
C:\Users\sallen>dir %PYTHONPATH%
Volume in drive C is System
Volume Serial Number is 96C6-CD68
Directory of C:\Presagis\Suite16\OpenFlight_API\bin_x64\release
02/08/2018 02:11 PM <DIR> .
02/08/2018 02:11 PM <DIR> ..
12/12/2016 12:27 AM 280,576 fltdata.dll
12/12/2016 12:27 AM 2,483,712 mgapilib.dll
12/12/2016 12:32 AM 279,252 mgapilib.py
02/08/2018 02:08 PM 258,180 mgapilib.pyc
12/12/2016 12:24 AM 65,024 mgdd.dll
12/12/2016 12:23 AM 157,696 mgmemory.dll
12/12/2016 12:24 AM 738,816 mgruntime.dll
12/12/2016 12:32 AM 1,216,000 _mgapilib.pyd
8 File(s) 5,479,256 bytes
2 Dir(s) 273,317,257,216 bytes free
C:\WINDOWS\system32>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import mgapilib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Presagis\Suite16\OpenFlight_API\bin_x64\release\mgapilib.py", line 7, in <module>
import _mgapilib
ImportError: DLL load failed: %1 is not a valid Win32 application.
>>>
To be clear, the python script is sitting in a folder with no other .py scripts, and as far as I know, the error I am getting is from the API install. The folder path is clearly bin_x64 yet the error message indicates, at a guess, a syntax error within the API.
I have made no changes to the API folder locations, not even copying my script files in there.
I do get a similar error from my script:
E:\>python sa_eggetattr2.py blip.flt
Traceback (most recent call last):
File "sa_eggetattr2.py", line 25, in <module>
from mgapilib import *
File "C:\Presagis\Suite16\OpenFlight_API\bin_x64\release\mgapilib.py", line 7, in <module>
import _mgapilib
ImportError: DLL load failed: %1 is not a valid Win32 application.
And running the ptest.py script:
from mgapilib import *
mgInit(None,None)
mgExit()
E:\>python ptest.py
Traceback (most recent call last):
File "ptest.py", line 1, in <module>
from mgapilib import *
File "C:\Presagis\Suite16\OpenFlight_API\bin_x64\release\mgapilib.py", line 7, in <module>
import _mgapilib
ImportError: DLL load failed: %1 is not a valid Win32 application.
System path includes
C:\Python278
C:\Python278\Scripts
Shawn, the output from your python interpreter suggests it is a 32 bit version of Python.
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
That will not work with a 64 bit version of the OpenFlight API.
Either find and install a 64 bit version of Python or set
PYTHONPATH and PRESAGIS_OPENFLIGHT_SCRIPT to the 32 bit folders of the OF API bin folder.
Shawn,
the output from your python interpreter suggests it is a 32 bit version of
Python.
Python 2.7.8 (default, Jun 30 2014, 16:03:49)
[MSC v.1500 32 bit (Intel)] on win32
That will not work with a 64 bit version of the OpenFlight API.
Either
find and install a 64 bit version of Python or set
PYTHONPATH and PRESAGIS_OPENFLIGHT_SCRIPT to the 32 bit
folders of the OF API bin folder.
Indeed, that is the problem! Thank you very much!!
E:\>python ptest.py
I: OpenFlight API version 16.0.0.
I: Loading plugin <OpenFlight Data Dictionary> from <C:/Presagis/Suite16/OpenFlight_API/bin_x64/release/fltdata.dll>...
I: Site <FLTDATA> registered for plugin <OpenFlight Data Dictionary>.
I: Plugin <OpenFlight Data Dictionary> loaded.
Shawn
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!
Code:
Presagis vars:
MPI_INSTALL_DEFAULT=C:\Presagis
PRESAGIS_CREATOR=C:\Presagis\Suite16\Creator
PRESAGIS_CREATOR_16_0=C:\Presagis\Suite16\Creator
PRESAGIS_LICENSING=C:\Presagis
PRESAGIS_OPENFLIGHT_API=C:\Presagis\OpenFlight_API
PRESAGIS_OPENFLIGHT_SCRIPT=C:\Presagis\OpenFlight_API\bin\release
PRESAGIS_ROOT=C:\Presagis
PYTHONPATH=C:\Presagis\OpenFlight_API\bin\release
From the interpreter I can see:
E:\utils>python
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>
import _mgapilib
ImportError: DLL load failed: %1 is not a valid Win32 application.
Help!
Thx