How to use project-relative path for Python scripts

If I put my scripts in a Python folder at the root of my project, they are supposed to be automatically recognized, but this isn’t the case for me.

If I add the Python dir an “Additional Paths”, it has to be an absolute path. Adding just “Python” doesn’t seem to work.

Is there no way to use a relative path for “Additional Paths”?

Any answer on that topic?

I am also curious about this. It’s a slight peeve to have to edit the path when migrating a project folder.

I’ve solved this historically with a custom plugin that uses init_unreal.py that appends a config ini defined value into sys.path. I’m actually in the process of submitting a plugin to FAB this week that should address this requirement a few other features. It will be free for personal and $5 for pro. This is what it looks like in my config right now:

You can inject additonal paths with ; as a delimiter which supports both absolute and project directory relative paths. I’ve also added support for applying the Editor Preferences > Data Source Folder that normally is globally set across the entire editor that will get scoped with this plugin to per project on start up.

If you’re trying to do this manually on your own, just add a file called init_unreal.py under your main Content/Python (shows up in Content Browser as /Game/Content asset path) or under any content plugin’s Python directory.

Inside you just need to put the following:

import sys
import os

my_relative_python_path = "../"
sys.path.append(os.path.realpath(unreal.Paths.project_dir() + my_relative_python_path))

Our plugin is now live on FAB: https://www.fab.com/listings/cb686537-d433-4b0d-a88a-cdf34f89d4f0

To see the plugin in action our demo video is here: https://www.youtube.com/watch?v=TnI8hVjyP20

Hope this helps.