installation - Python: TypeError when running script but not in interpreter -


i trying run python file via command line or within interpreter using:

import sys import subprocess subprocess.call([sys.executable, "file.py", "arg1", "arg2", "arg3"]) 

however program returns typeerror: "cannot concatenante 'str' , 'numpy.float64' objects".

what can not understand, when run program line line in interpreter, there no such errors , fine.

i have no idea start debugging suspect have setup.

i have 64bit version of python , 32bit version of python installed in windows 7. both versions of python 2.7. (this due usage of modules available in 32 bits - such program above being running in 32 bit version). environment path variable has been edited use 32bit version.

i'm not sure other information relevant please let me know , i'll dig up.

basically want able run program command:

python program.py arg1 arg2 arg3 

any appreciated

you passing arguments function without converting them string representations - when test code in interpreter , provide numbers will, of course, work expected. if doing this:

# wild guess @ code looks  if __name__ == "__main__":     # main_function(23.1, 44.9, 12.21)  # works when uncommented ... why?     main_function(sys.argv[1], sys.argv[2], sys.argv[3])  # breaks ... why? 

then know when call:

python program.py 23.1 44.9 12.21 

you calling main_function following:

main_function("23.1", "44.9", "12.21") 

you'll need explicitly convert arguments floats float type constructor.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -