Skip to content Skip to sidebar Skip to footer

Environment Variables Not Evaluated In Program Parameters In Windows Pycharm

Trying to run the wordcount.py example from the data-flow quickstart example via pycharm, and I ran into an issue when parsing the command line arguments that contain environment v

Solution 1:

When you pass environment variables as values for the parameters (e.g., --project, --temp_location) to Pycharm configuration, it takes those variables as "string" values instead of their real values which you set on the first screenshot "User environment variables". I did a quick search for many related threads on StackOverflow but not find a solution so I came up with my own one, that is, using your current settings and replacing the values after parsing arguments in your code:

# Args parsing here

if args.project == "${PROJECT}":
    args.project = os.environ.get("PROJECT")
    args.temp_location = args.temp_location.replace("${BUCKET}", os.environ.get("BUCKET"))

However, I think you should consider using it when

  • you work with PyCharm more frequently than Terminal.
  • there are many arguments referring to environment variables and you have to change their values for different settings.

Hope Pycharm will support this feature soon.

Post a Comment for "Environment Variables Not Evaluated In Program Parameters In Windows Pycharm"