Skip to main content

I have set environment variable which I am able to access in terminal. But in workbench. Is there any setting need to access this variable ? Trying to access using 

 

os.environ.get('FME_LOCAL_OUTPUT')

 

This is python startup script where some logging activity is doing. 

 

This is working in FME server. Same thing am trying to replicate on local machine.

 

Log of error : 

 

Starting translation...
('printing path', None)
Traceback (most recent call last):
  File "<string>", line 19, in MF_Include_161192722330
  File "<string>", line 6, in ParamFunc
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 70, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
 
 
INCLUDE -- failed to evaluate Python script `def ParamFunc():
  import os, time, re
 
  temp_output_path = os.environ.get('FME_LOCAL_OUTPUT')
  print("printing path", temp_output_path)

 

If you cannot retrieve the new environment variable using the EnvironmentVariableFetcher, then it may be out of scope. Note that environment variables are local to each process, and a running process (e.g. FME) does not automatically pick up new environment variables that are defined in another context (e.g. the command line).

Try setting the environment variable on the user or machine level and restart FME. If that still doesn't work, it may be necessary to log yourself out and in again.


If you cannot retrieve the new environment variable using the EnvironmentVariableFetcher, then it may be out of scope. Note that environment variables are local to each process, and a running process (e.g. FME) does not automatically pick up new environment variables that are defined in another context (e.g. the command line).

Try setting the environment variable on the user or machine level and restart FME. If that still doesn't work, it may be necessary to log yourself out and in again.

I tried restarting FME. Same things is working in FME server ( Window OS ). Only i am trying to run FME script on my local machine ( MacOS) using FME workbench.


I got answer. In different we need to set environment variable for launch Agent ( Application level) . 

Create the plist file under ~/Library/LaunchAgents/:
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>my.startup</string>
 <key>ProgramArguments</key>
 <array>
 <string>sh</string>
 <string>-c</string>
 <string>launchctl setenv RV_OS_PATH_OSX /volumes/zdisk;
launchctl setenv RV_OS_PATH_WINDOWS Z:;</string>
 
 </array>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>
To activate the environment.plist (assuming you named it environment.plist), run
 
launchctl load ~/Library/LaunchAgents/environment.plist
launchctl start ~/Library/LaunchAgents/environment.plist

Here is reference : https://support.shotgunsoftware.com/hc/en-us/articles/219042108-Setting-global-environment-variables-on-OS-X 


Reply