physica Posted October 29, 2015 Posted October 29, 2015 I'm starting to learn python for post grad. However, I am having trouble utilising it. I can run code in the terminal via text wrangler. This works fine however, if I try and run it by itself it comes up with NameError: name raw_input("Enter name: ") I then downloaded IDLE and python launcher from python.org. However, it gives the same error message. It seems that I can only run by code through the terminal (I'm on mac). I am also at a loss on how to compile programs. I have no idea how to use python launcher and I can't find any tutorials. Can anyone point me in the right direction for guidance? Many thanks
pwagen Posted October 29, 2015 Posted October 29, 2015 From what I can find, raw_input was renamed input at some point. Might be worth replacing it and trying again.
Klaynos Posted October 29, 2015 Posted October 29, 2015 Are the GUIs running the same version of python as you run in the terminal? Is python ever compiled? Is it not always run through an interpreter?
moth Posted October 29, 2015 Posted October 29, 2015 Do you need to add a line to the Python code file telling the shell to load the python interpreter?the first line has to be: "#!/bin/python" (no quotes) for bash on Linux but it might be different on your OSIf you dig around Python.org for a while, you'll probably find the answer look for python script for the shell or so.
fiveworlds Posted October 29, 2015 Posted October 29, 2015 Do you need to add a line to the Python code file telling the shell to load the python interpreter? the first line has to be: "#!/bin/python" (no quotes) for bash on Linux but it might be different on your OS It's the path to the .exe file you are using not #!/bin/python it just tends to be installed there on Linux. 1
ydoaPs Posted October 30, 2015 Posted October 30, 2015 I'm starting to learn python for post grad. However, I am having trouble utilising it. I can run code in the terminal via text wrangler. This works fine however, if I try and run it by itself it comes up with NameError: name raw_input("Enter name: ") I then downloaded IDLE and python launcher from python.org. However, it gives the same error message. It seems that I can only run by code through the terminal (I'm on mac). I am also at a loss on how to compile programs. I have no idea how to use python launcher and I can't find any tutorials. Can anyone point me in the right direction for guidance? Many thanks It looks like your version of IDLE is python 3 and your version of input is python 2. 1
physica Posted October 30, 2015 Author Posted October 30, 2015 Thanks for the input. To be honest I am very new to this so when you guys talk about shells etc I am a bit lost. Is there a download you can recommend for a starter? I want to get used to the syntax and write some very basic programs so I can get a hang of the basics. Yes I downloaded python 3 but I have been learning how to code from code academy.com. I am not sure if codeacademy.com is teaching in python 2.
moth Posted October 30, 2015 Posted October 30, 2015 Python.org says codeacademy is using python 2.0.The shell or CLI is generally when you are typing commands or program names to be executed instead of clicking on an icon with a mouse."how to think like a computer scientist" had some good tutorals, but it looks like it's been updated since the last time I was there so it may or may not be worth checking. 1
physica Posted October 30, 2015 Author Posted October 30, 2015 Many thanks. I have downloaded python 2 from python.org and it runs with no problems. Considering that I have gotten fairly far on code academy and I will not be writing the most complex programs I will stick with this. Many thanks for the help. Before this thread I didn't even know there was 2 versions of python. Will look into compilers.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now