Cannot set environment variables through remote debugging?


I have been trying to do some remote debugging on linux servers from my ubuntu local machine and have been unable to setup the environment correctly. We have an sh script that runs on the remote machines which sets up some of the global variables and other dependencies right before out python scripts run. This works perfectly fine on the remote servers and has been for years. However I have been unable to get PyCharm to run this script to run correctly before entering the remote debugging session remotely. Here are the things I have tried:

  1. Adding the script as a "Remote External Tool" in the Rub/Debug config. This didn't work because although the script gets executed the environment variables do not get set and I get an import error for Spark.
  2. Adding variables as "Environment variables" in the Run/Debug config. This did not work because I still received an import error for Spark
  3. Create a separate python script and add the env variables before runtime, the script executes but the environment variables are not set.
    os.environ["SPARK_HOME"] = "/opt/cloudera/parcels/CDH/lib/spark"


There are other things that the script does, but for the time being I am just trying to get these environment variables set, which should be a pretty simple task, and it is frustrating that this is not something straightforward in PyCharm.


We submitted the issue about it: