I'm a bit of a noob when it comes to coding and I've been using sublime text to run python and I had followed a tutorial to create a build engine which ran my code through Python 3. On most pieces of code I seem to run python 3. ie print "Hello" doesn't do anything. For some weird reason I was using the input command and it wasn't working, but when I tried raw_input (the input command for python2) it did work. I'm really confused and any clarification or help would be greatly appreciated.
Asked
Active
Viewed 51 times
-1
-
Do `import sys;print(sys.version_info)` – snakecharmerb Apr 29 '20 at 08:28
-
@snakecharmerb it returns this, (major=3, minor=7, micro=3, releaselevel='final', serial=0), when i run just the version it says 3.7.3, but then the input command doesn't seem to work. – Rev_Giraffe Apr 29 '20 at 08:43
-
Does this answer your question? [How do I check what version of Python is running my script?](https://stackoverflow.com/questions/1093322/how-do-i-check-what-version-of-python-is-running-my-script) – Joe Apr 29 '20 at 09:04
-
I really don't know what you want to achieve here. ie, Having your code run with a specific python version or know the version you're working with? It will also be useful if you share snippets of your code and the command you use to run the code. – Joseph Kasule Apr 29 '20 at 09:06
-
When I run the sys version command I get this: 3.7.3 (default, Apr 7 2020, 14:06:47) [Clang 11.0.3 (clang-1103.0.32.59)] [Finished in 0.1s] When I run a command like this: mood = input("How are you going?") print(mood) When I run that code it has a traceback error, Traceback (most recent call last): File "import sys.py", line 1, in
mood = input("How are you going?") File " – Rev_Giraffe Apr 29 '20 at 22:09", line 1, in NameError: name 'good' is not defined However if I change it too raw_input it works all fine, the problem is that raw_input is a python2 command.
1 Answers
0
first of all print "hello" work in python 2 not python 3( print("Hello") will work)
python 2 :
print "Hello"
x=raw_input()
python 3 :
print("hello")
x=input()
To print version of python:
import sys
print(sys.version)
Be sure two version of python is not installed on your system (Anaconda python and python)

Tomato Master
- 496
- 3
- 10