您可以使用sys.path它来查找您的当前目录,并将您的模块包含在其中sys.path以便 Python 可以找到它。但是,这个解决方案有点乱:import sysimport os# Get current directorycurrent_dir = sys.path[0]# Create path to 'Main Folder/DataManagement/Libraries'search_dir = os.path.join(current_dir.split('DataUsage')[0], 'Libraries')# Make Python search for new pathsys.path.append(search_dir)from TransformLibrary import transform # transform.py is imported