How to stop importing line arguments with imported file
I have two programs train.py and predict.py and I am importing a trained model from train to predict.
Both programs accept line arguments and train runs fine, but when I run predict with its line arguments, an error occurs that I haven't typed in the arguments required by train.py.
How I can solve this?

Your question could use some more context. But here is what suspect might be happenning :
context
When you import a file (module), its content is executed. If your file only contain declarations (such as variable, class and function definitions) all is good, and you can use them from the place you wrote your import statement.
Now if the module you import contain actual code like function calls, it's going to run !
It's likely that your train.py file is expecting functions that fail (by missing some arguments apparently).
The usual solution to avoid this is to wrap all calls in a if __name__ == &quot;__main__&quot;: clause. That way, it will only be executed if that file is called directly (as opposed to imported).
tl;dr:
Look into your train.py file for function calls
def a_function():
    pass

class SomeClass:
   pass

a_function() # &lt;--- this is a call

my_var = SomeClass() # &lt;--- this too !

and put them in that clause
def a_function():
    pass

class SomeClass:
   pass

if __name__ == &quot;__main__&quot;:
   #only executed if you call this file (python train.py)
   a_function() 
   my_var = SomeClass() 

