Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell what version of Python a script needs?

I'm looking at some Python scripts on GitHub, but the developer doesn't specify what version (2.7 or 3.x) of Python is required.

Is there any way to tell? What type of execution errors should I look out for when a Python script fails due to version mismatch?

like image 769
Jeff Avatar asked Sep 19 '25 10:09

Jeff


1 Answers

A version mismatch between Python 2 and 3 is fairly simple to find.

In python 2, print is used without brackets, for example: print "hello"

While in python 3, print is used with brackets, such as: print("hello")

Python also frequently has easy-to-read errors for differences in such where the error would end with did you mean X?

Also to input something in the command line, python 2 uses raw_input while python 3 uses input

like image 104
hypadr1v3 Avatar answered Sep 21 '25 00:09

hypadr1v3