1

I am trying to run a python (test.py) file in Colab. The file needs inputting some parameters, e.g., "--epoch", "--class_file". What I did is:

!python test.py "--epoch" 100 "--class_file" class_file
#class_file is a path string 

After argument parsing, the class_file is not interpreted as the intended path string, but instead a string like class file = "class_file". How did that happen?

jwm
  • 4,832
  • 10
  • 46
  • 78
  • What happens if you remove all quotation marks from the command? – rchurt Jul 19 '20 at 19:59
  • It does not help. Still gives the error: FileNotFoundError: [Errno 2] No such file or directory: 'classes_file' – jwm Jul 23 '20 at 20:39

1 Answers1

3

Put the argument variable in a curly brackets {}: !python test.py "--epoch" 100 "--class_file" {class_file}.

Refer to a post Notebooks: Passing string variables as arguments to python script via command line(!), using quotes And $, eg -arg1 '$varible1'

jwm
  • 4,832
  • 10
  • 46
  • 78