diff --git a/python_files/python_server.py b/python_files/python_server.py index 1689d9b8f7f9..46c4187e35c9 100644 --- a/python_files/python_server.py +++ b/python_files/python_server.py @@ -5,6 +5,7 @@ import sys import traceback import uuid +from pathlib import Path from typing import Dict, List, Optional, Union STDIN = sys.stdin @@ -172,6 +173,12 @@ def get_headers(): if __name__ == "__main__": + # https://docs.python.org/3/tutorial/modules.html#the-module-search-path + # The directory containing the input script (or the current directory when no file is specified). + # Here we emulate the same behavior like no file is specified. + input_script_dir = Path(__file__).parent + sys.path.remove(str(input_script_dir)) + sys.path.insert(0, str(Path.cwd())) while not STDIN.closed: try: headers = get_headers()