I am learning python from learnpythonthehardway. In Windows I had no issues with going through a lot of the exercises because the setup was easier, but I want to learn Linux as well and Ubuntu seemed to me the nicest choice.

Now I am having trouble with setting up. I can get access to the terminal and then /usr/lib/python.2.7, but I don't know if I should save the script in this directory? If I try to make a directory inside this through mkdir I can't as permission is denied. I also tried to do chmod but didn't know how or if to do it.

How can I correctly save my script? I would like to be able to run the script like this: user@user$ python sampleexcercise.py and have it work.

I'm using Ubuntu 12.04.


You can save your code in your home directory - normally /home/(your username)/ or ~/ for short. Once you've saved your code you should be able to call it from python by using

$ python ~/myCode/example1.py

if your code was in a folder called myCode (also note that folder & file names are case sensitive)

You don't need to be in the directory /usr/bin/ to run python as that folder is part of your $PATH - which means it's accessible no matter which folder you're in.

You may also want to use IDLE, a commonly used GUI for python. You can install it by searching in the Software Center or by running

$ sudo apt-get install python-idle

  • thanks. really helped. I was actually making the files in desktop than in the home directory... – user1837259 Nov 20 '12 at 0:31
  • 1
    The desktop is within your home directory :) – Marcin Kaminski Nov 20 '12 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.