Python Environment Variable Changes for UE5

Python Environment Variable Changes for UE5

Article written by Cody A.

In Unreal Engine 4, the standard Python* environment variables (PYTHONPATH, PYTHONHOME, etc.) were made available for use within the editor, and added to ‘sys.path’. This could cause compatibility issues when other Python installations were configured on the machine, since Unreal includes its own embedded Python installation locked to a specific version (3.7.7 at the time of publication).

In Unreal Engine 5, we’ve added an IsolateInterpreterEnvironment flag that is enabled by default. We’ve also added support for a new environment variable, UE_PYTHONPATH, which will be added to sys.path as before to avoid the editor including incompatible scripts that were added by other applications. If you wish to restore the previous functionality, you can disable isolation mode in Project Settings->Plugins->Python and the editor will again be able to access the standard Python environment variables. Note that the UE_PYTHONPATH variable will still be available regardless of this setting. In the event that you encounter any Python-related crashes with isolation disabled, it’s recommended that you enable it to rule out interference from any external Python scripts.

See more on the Knowledge Base.

3 Likes

That’s great!

Is there a way to edit UE_PYTHONPATH from a plugin’s module? I would like to make Python modules stored in the plugin available to use in the UE project.