Jump to content

Utilising Python

Featured Replies

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

From what I can find, raw_input was renamed input at some point. Might be worth replacing it and trying again.

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
If you dig around Python.org for a while, you'll probably find the answer look for python script for the shell or so.

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.

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.

  • Author

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.

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.

  • Author

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.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.