In Windows, the file types are identified by the last 3 chars after the . However, in linux (and in Ubuntu) .py just helps us humans figure out what kind of file it is. You have to tell Ubuntu that the script you wrote is a python script and it should be run with a python interpreter. You can do this in two ways:
First you can call python
followed by the name of the script. That is open a terminal and type:
python hellowworld.py
This will work.
Second, however, you want to use the GUI and run it by double clicking. To this you need a line in the script that tells Ubuntu that the next lines are to be interpreted as a python script. This first line is called the shabang line. For python it looks like:
#! /usr/bin/python
Note the #!
at the beginning. The first two characters of your script must be those two followed by the rest of the line. So your script will look like:
#! /usr/bin/python
print"hello world"
vary = raw_input("Enter your Name")
print ("hey " + vary)
As you noted the script must be tagged as executable. To do that, right click on the script's icon and go to Properties>Permissions and check Allow executing file as program.
Now when you double click on the script it will show you a Window with the choices:
Run in terminal
, Display
, Cancel
, Run
You can try Run in terminal
. It will open a terminal and show you the prompt:
Enter your name
When you enter your name the terminal will close as the script completes. So you will never see "hey [your name]" as it will happen too fast for your eyes to catch it. You will have to modify the script so that it pauses and wait for you to dismiss it after you see the display.
Hope this helps
As ByteCommander said in a comment, PyCharm doesn't use bashrc, so it doesn't know where your library is.
In the same screen where you added the interpreter you can see a wheel icon, click it, it will show you a menu, click on more. You should see a screen like this:
![PyCharm Interpreter configuration](https://i.stack.imgur.com/u2Lfe.png)
You should select your interpreter and click on the last button. This should open this window:
![Interpreter paths configuration](https://i.stack.imgur.com/bjs7M.png)
Now clicking on the plus icon you should be able to add your own paths for libraries.
Best Answer
Don't do it
Since many important programs are written in python changing default python may crash your system, so set python for individual apps. You can locate python3 at
/usr/bin/python3
.If you want python3 by default try Ubuntu 12.10