Skip to main content

I have a module . in a folder (called '/wscloud/email_automation/wsa/lib')

I can import it if I append the path explicitly, but this seems like a very clumsy way to do this. Is there a way I can configure the import path in settings?

Thanks,

 

Fuad.

-----

import fmeobjects

 

import sys

 

sys.path.append('/wscloud/email_automation/wsa/lib') #ew!

 

import wsa

Instead of modifying sys.path, paths can also be specified in the PYTHONPATH environment variable.


Instead of modifying sys.path, paths can also be specified in the PYTHONPATH environment variable.

Ah, thanks! Do you know how/where I do this on a Mac (macOS Sierra) so the change is permanent?

 

 


Ah, thanks! Do you know how/where I do this on a Mac (macOS Sierra) so the change is permanent?

 

 

I think you can modify ~/.bash_profile and add 'export PYTHONPATH=foo'.

Instead of modifying sys.path, paths can also be specified in the PYTHONPATH environment variable.

I did that and it works if I run python in Terminal

 

 


>>> import wsa

 


>>> import sys

 

>>> print sys.path

 


r'', '/wscloud/email_automation/wsa/lib', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Sy...

 

..

 

 

but it still fails to import in FME

 

My command-line python path is very different from the one FME gives me if I print sys.path from each.

 

 

I think that successfully initialized bash, but not FME (but I'm out of my depth here)
I did that and it works if I run python in Terminal

 

 


>>> import wsa

 


>>> import sys

 

>>> print sys.path

 


r'', '/wscloud/email_automation/wsa/lib', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Sy...

 

..

 

 

but it still fails to import in FME

 

My command-line python path is very different from the one FME gives me if I print sys.path from each.

 

 

I think that successfully initialized bash, but not FME (but I'm out of my depth here)
After modifying .bash_profile, you may need to restart your machine for the change to fully take hold.

 

 


Instead of modifying sys.path, paths can also be specified in the PYTHONPATH environment variable.

I shutdown and restarted but I have the same problem - Python in Terminal is good, but FME python does not know about PYTHONPATH :(

 

 


I shutdown and restarted but I have the same problem - Python in Terminal is good, but FME python does not know about PYTHONPATH :(

 

 

I asked around, and unfortunately it turns out Macs behave differently here, and Workbench won't pick up environment variables this way. You might have to stick with doing it the ugly way. You can also try putting the Python module and its dependenciesin the same directory as the FME workspace, if that's possible in your use case.

Instead of modifying sys.path, paths can also be specified in the PYTHONPATH environment variable.

Thanks for digging in - as a recovering PC guy and now Mac guy, usually things go the other way! I will try a sym link and if that fails, and an actual copy as fallback.

 

 


Yup - putting a sym link to the include path in the folder that contains the workspace solves this. Thanks Carson!!!


Reply