Skip to main content

I’m trying to discover why my stand-alone python script cannot now ‘import fmeobjects’ after an upgrade of FME Desktop 2022.2 to FME Forms 2023.2.2.

The sys.append path that worked previously had a python version subfolder inside the installation’s fmeobjects folder, like this:

if os.path.isdir(rf"{FME_HOME}\fmeobjects\{python_subfolder}"):
os.add_dll_directory(FME_HOME)
sys.path.append(rf'{FME_HOME}\fmeobjects\{python_subfolder}")
sys.path.append(FME_HOME)
os.chdir(FME_HOME)
import fmeobjects

but those python subfolders are no longer there inside the fmeobjects folder in the Form current installation, but rather are outside in their own ‘python’ folder now. Is this correct? It seems that most of the searching I’ve done has the path to the python version as a subfolder of fmeobjects folder.

No amount of appending sys.path versions of the python_subfolder will allow python to correctly ‘import fmeobjects’ and not stop producing:

ImportError: DLL load failed while importing fmeobjects: The specified module could not be found.

What gives? TIA

Brian

 

It looks like they’ve moved into the python folder

"C:\Program Files\FME 2023.2.1\python\fmewebservices.cp311-win_amd64.pyd"


I tried setting the append to the {FME_HOME}\python but still cannot import fmeobjects. How can I get python to recognize it?


I got it working on 3.10 with:

import os, sys


fme_dir =  'C:\Program Files\FME 2023.2.1'
os.add_dll_directory(fme_dir)


fme_py = os.path.join(fme_dir, 'python')
sys.path.append(fme_py)


import fmeobjects
help(fmeobjects)

 


It odd but the exact same code fails here:

    fme_dir = r"<path-to-FME-home>"
    os.add_dll_directory(fme_dir)

    fme_py = os.path.join(fme_dir, "python")
    sys.path.append(fme_py)

    import fmeobjects

    help(fmeobjects)

Traceback (most recent call last):
  File "<path-to-testing>.py", line 51, in <module>
    import fmeobjects
ImportError: DLL load failed while importing fmeobjects: The specified module could not be found.

Your thoughts?

 

Thanks for this,

Brian


It odd but the exact same code fails here:

    fme_dir = r"<path-to-FME-home>"
    os.add_dll_directory(fme_dir)

    fme_py = os.path.join(fme_dir, "python")
    sys.path.append(fme_py)

    import fmeobjects

    help(fmeobjects)

Traceback (most recent call last):
  File "<path-to-testing>.py", line 51, in <module>
    import fmeobjects
ImportError: DLL load failed while importing fmeobjects: The specified module could not be found.

Your thoughts?

 

Thanks for this,

Brian




What version of python are you using?


Actually our systems tech wiz discovered the sequence of commands that made it work:

fme_home = r"<path-to-fme>"
fme_py = os.path.join(fme_home, r"python")
fme_dir = os.path.join(fme_py, r"fmeobjects")
sys.path.append(fme_dir)
sys.path.append(fme_py)  # add this
os.chdir(fme_home)  # do this too (somehow needed)
import fmeobjects

print(fmeobjects)

Thanks for your helpful input!

Cheers...Brian


I’m working with FME 2024.2 on Windows 10 using the Python 3.11 libraries installed with ArcGIS Pro. I’ve also had some trouble with this, but have found a solution.

There appears to be a fme.dll file in the C:\Program Files\FME\loader which is important.

The solution I found is as follows:

fme_home =  r"C:\Program Files\FME"
fme_py = os.path.join(fme_home, r"python")
fme_dll = os.path.join(fme_home, r"loader")
sys.path.append(fme_py)
os.add_dll_directory(fme_home)
os.add_dll_directory(fme_dll)
import fmeobjects

 


I’m working with FME 2024.2 on Windows 10 using the Python 3.11 libraries installed with ArcGIS Pro. I’ve also had some trouble with this, but have found a solution.

There appears to be a fme.dll file in the C:\Program Files\FME\loader which is important.

The solution I found is as follows:

fme_home =  r"C:\Program Files\FME"
fme_py = os.path.join(fme_home, r"python")
fme_dll = os.path.join(fme_home, r"loader")
sys.path.append(fme_py)
os.add_dll_directory(fme_home)
os.add_dll_directory(fme_dll)
import fmeobjects

 

 ​@thejando : We recently updated to Python 3.11 and our previous solution stopped working so I’ve implemented your solution. It works fine to import the fmeobjects but if I try to implement any calls with it, like creating a log file, it totally crashes the python script:

logger_FME = fmeobjects.FMELogFile()  # ISSUE: crashes here. Doesn't throw Exception


Just give a popup window with: ‘Application has stopped working’ in the popup title and: Please wait while we gather information about the error…
Are you able to create an instance of the fmeobjects.FMELogFile() class?
TIA,
Brian


Hi ​@blueinc,

After updating your os.path with the fme folders, please add:

import os

# Modify the path if FME is installed in another location
os.environo'FME_HOME'] = r"C:\Program Files\FME"

import fmebootstrap
import fmeobjects

 


Thanks for your reply ​@daveatsafe Now getting:
ImportError: DLL load failed while importing fmeobjects: A dynamic link library (DLL) initialization routine failed.
 

fme_home = r"E:\sw_nt\FME"
os.environi'FME_HOME'] = r"E:\sw_nt\FME"
fme_py = os.path.join(fme_home, r"python")
fme_dll = os.path.join(fme_home, r"loader")
sys.path.append(fme_py)
os.add_dll_directory(fme_home)
os.add_dll_directory(fme_dll)
sys.path.append(fme_home)  # try adding to sys.path?
sys.path.append(fme_dll)  # try adding to sys.path?
os.chdir(fme_home)  # do this (somehow needed)

import fmebootstrap
import fmeobjects

Fails on the last line importing fmeobjects

p.s. changed the order slightly; same result:   

    fme_home = r"E:\sw_nt\FME"
fme_py = os.path.join(fme_home, r"python")
fme_dll = os.path.join(fme_home, r"loader")
sys.path.append(fme_py)
os.add_dll_directory(fme_home)
os.add_dll_directory(fme_dll)
sys.path.append(fme_home) # try adding to sys.path?
sys.path.append(fme_dll) # try adding to sys.path?
os.environs'FME_HOME'] = fme_home
os.chdir(fme_home) # do this (somehow needed)

import fmebootstrap
import fmeobjects

 


Hi ​@blueinc,

Are you running Python 32 bit or 64 bit?


Python 3.11.10 64-bit


Hi ​@blueinc,

I installed Python 3.11.10 and FME 2023.2.2 on a clean pc, with no other major apps, and was able to run the following:
 

with the results:

 

We have had clients who have had conflicts when running FME Objects in the Python installed with ArcGIS, due to ArcGIS supplying older MS C++ runtimes. This can usually be solved by renaming the ArcGIS runtime DLLs to disable them, forcing ArcGIS to use the newer FME supplied runtimes.

It may be possible that you have a runtime conflict due to another application that might be using an older version. What other applications do you have on that computer? FME installs its runtimes in the Windows\System32 folder so they should be the default, but you could search for other copies of msvcp140.dll.


Thanks so much for looking into this.

I work on a network server that has many apps installed. Primarily, we are a mapping shop, and you are correct: we use a clone of the default ArcGIS Python installation that we add separate modules to as needed. I will let our systems tech wiz know of this latest.

Cheers...Brian


Reply