title: How to get around java.lang.UnsupportedOperationException: Can't modify environment?
body: <p>I'm trying to run a sub process on Android (see <a href="https://stackoverflow.com/questions/4568588/is-there-a-commandline-flag-to-set-pythonhome">this question</a>) which requires that the PYTHONHOME environment variable be set.  I tried to do so with the following code:</p>
  
  <pre><code>    ProcessBuilder pbuilder = new ProcessBuilder("python/bin/python", "test.py");
      pbuilder.directory(getFilesDir());
      Map&lt;String, String&gt; env = pbuilder.environment();
      env.put("PYTHONHOME", "python");
  
      Process process = pbuilder.start();
  </code></pre>
  
  <p>but I get this exception:</p>
  
  <pre><code>E/AndroidRuntime(25857): FATAL EXCEPTION: main
  E/AndroidRuntime(25857): java.lang.UnsupportedOperationException: Can't modify environment
  E/AndroidRuntime(25857):    at java.lang.SystemEnvironment.put(System.java:740)
  E/AndroidRuntime(25857):    at java.lang.SystemEnvironment.put(System.java:688)
  E/AndroidRuntime(25857):    at my code
  E/AndroidRuntime(25857):    at android.view.View.performClick(View.java:2408)
  E/AndroidRuntime(25857):    at android.view.View$PerformClick.run(View.java:8816)
  E/AndroidRuntime(25857):    at android.os.Handler.handleCallback(Handler.java:587)
  E/AndroidRuntime(25857):    at android.os.Handler.dispatchMessage(Handler.java:92)
  E/AndroidRuntime(25857):    at android.os.Looper.loop(Looper.java:123)
  E/AndroidRuntime(25857):    at android.app.ActivityThread.main(ActivityThread.java:4627)
  E/AndroidRuntime(25857):    at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(25857):    at java.lang.reflect.Method.invoke(Method.java:521)
  E/AndroidRuntime(25857):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  E/AndroidRuntime(25857):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  E/AndroidRuntime(25857):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Does anyone have any advice?  I've tried wrapping the call to python in a shell script which exports PYTHONHOME but that didn't do the trick.</p>
  
  <p>Gabe</p>