I have a series of rather complicated codes that I developed on a Linux machine, run on a Unix cluster and from time to time need to run on a Windows machine to gain access to a private network. They are all running Python 3.6 and I have not had a lot of success moving the subprocess.call or similar command between platforms.The codes do not take any inputs and I want to be able to run them on their own, therefore, I do not want to make them function that I call from another script.  Currently, the only way that I have found to run the codes is to import the code on the first time it is called and then recall it using  importlib.reload(Code_2_NLLS_capacity) the next time.Here is an example (Added for simplicity as it is easier to read) of what I am doing:import importlib as imlfor i in range(10):        if i == 0:        import Code_1        import Code_2        import Code_3        import Code_4    else:        iml.reload(Code_1)        iml.reload(Code_2)        iml.reload(Code_3)        iml.reload(Code_4)This works well enough for a loop, but it gets rather complicated when I try to run the codes out of order.  Lastly, the code takes a fairly long time to run (5+ hours per code) so I do not want to simply pre import the code and then reload the code as needed.The following code is my actual code. It is run on a cluster machine that provides a .out file of the terminal. This is why errors are ignored and I print large dividing headers.#!/usr/bin/env python3# -*- coding: utf-8 -*-This code runs all the other codes in the system.@author: downey#ignore warings to prevent large file sizes on .out filesimport warningswarnings.filterwarnings('ignore')import matplotlib.pyplot as pltimport numpy as npimport pickle as pickleimport os as osimport importlib as imlplt.close('all')#%% Build the dynamic bounds data set#set the bound limitsbound_limits = np.arange(0.05,.8,0.05)# for each bound limit, build the linear bound, and cycle though all the codefor bound_i in range(bound_limits.shape[0]):    # set the battery life in cycles, so the dynamic bound reaches its target    mass_pos = np.zeros((250,8))    dynamic_bounds = np.zeros(mass_pos.shape[0])    dynamic_start = 0    dynamic_end = bound_limits[bound_i]    x_bounds = np.arange(0,mass_pos.shape[0])    dynamic_bounds = np.interp(x_bounds, [0,mass_pos.shape[0]], [dynamic_start,dynamic_end])    plt.figure()    plt.plot(x_bounds,dynamic_bounds)    plt.xlabel('number of charge cycles')    plt.ylabel('enforced bounds on the NLLS')    plt.title('dynamic bounds on the NLLS')    os.chdir('data')    pickle.dump(dynamic_bounds,open('dynamic_bounds_temp.pickle','wb'))    os.chdir('..')    #%% run the codes    # buid the data sets    if bound_i == 0:        import Code_1_build_data_sets        # run the NLSS on a parameter basis        import Code_2_NLLS_capacity        import Code_2_NLLS_slip_pos        import Code_2_NLLS_mass_neg        import Code_2_NLLS_mass_pos        # solve the half cell model on a model basis        print('***********************************************************************\n Code_3_cell_prognostics_model_1\n***********************************************************************')        import Code_3_cell_prognostics_dynamic_bounds        import Code_4_RUL_dynamic_bounds        else:        iml.reload(Code_1_build_data_sets)        # run the NLSS on a parameter basis        iml.reload(Code_2_NLLS_capacity)        iml.reload(Code_2_NLLS_slip_pos)        iml.reload(Code_2_NLLS_mass_neg)        iml.reload(Code_2_NLLS_mass_pos)        # solve the half cell model on a model basis        print('***********************************************************************\n Code_3_cell_prognostics_model_1\n***********************************************************************')        iml.reload(Code_3_cell_prognostics_dynamic_bounds)        iml.reload(Code_4_RUL_dynamic_bounds)
Run one Python script from another on Windows, Linux and Unix machines that use the same code
python;linux;unix