Skip to main content
Hi all?

 

 

I import a customized module in the Startup Python Script?when I run it under the workbench ?it‘s all right. But when run it under the command line, it failed with python importerror ?No module named ...

 

 

Can any one tell me why?

 

Thanks
Hi,

 

 

are you sure that the fme.exe called by the command line is the same as the one used inside the Workbench? Might you have more than one version of FME installed?

 

 

Try the following from the command line:

 

 

fme.exe python

 

>>> import your_module_here

 

 

What does it say?

 

 

David
Hi David,

 

 

Thanks for your advice, I installed FME server and desktop. The default EnvironmentVariable set  server path variable  before  desktop's. I changed it and everything is ok!

 

 

Thanks a lot !

 

 

LarryDai

 

 

 


Good to hear you found a solution.

 

 

Tip: when using batch files, never rely on the PATH settings to find the executable, use a complete path reference to the executable, e.g.

 

 

c:\\apps\\fme\\fme.exe <parameters>

 

 

David
Hi,

 

 

Another tip: module path searching can be also resolved in source code level. Add these lines before importing your module in the startup script.

 

-----

 

import sys

 

sys.path.append('your_module_directory_path')

 

import your_module_here

 

-----

 

 

FYI.

 

Takashi
Takashi, that is a good tip, but I'd be a bit careful since there is a slight risk that you'd end up pointing at Python modules compiled for a different version, as well as possible naming collisions with different versions of the standard modules, etc.

 

 

David
David, thanks for the pointing out. Agree that there is such a risk.

 

Version management could be troublesome if adopting the approach.

Reply