Take the 2-minute tour ×

I am learning python from learnpythonthehardway. in the windows I had no issues with going through a lots of 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 to 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.

any help regarding how to save my script in what libary? how to do that? and how to run it in terminal as: user@user$ python sampleexcercise.py

using ubuntu 12.04 lts skill = newbie

thanks in advance.

share|improve this question
You save your own scripts in your own home folder. The files and folders in /usr are all system files and folders. –  Joachim Pileborg Nov 19 '12 at 23:51
Also, when you try to run your script, what happens? What errors (if any) do you get? If you get errors, please edit your question to include them all and complete. –  Joachim Pileborg Nov 19 '12 at 23:53
add comment

1 Answer

up vote 2 down vote accepted

As an absolute beginner, don't worry right now about where to install libraries. Simple example scripts that you're trying out for learning purposes don't belong being installed in any lib directory such as under /usr/lib/python.'

On Linux you want to do most work in your home directory, so just cd ~ to make sure you're there and create files there with an editor of your choice. You might want to organize your files hierarchically too. For example create a directory called src/ using the mkdir command in your home directory. And and then mdkir src/lpthw, for example, as a place to store all your samples from "Learn Python the Hard Way". Then simply fun python <path/to/py/file> to execute the script. Or you can cd ~/src/lpthw and run your scripts by filename only.

share|improve this answer
This is really true even on Windows—you shouldn't be putting scripts you're writing inside C:\Python27 or whatever. But you get away with it because of the oddities of Windows's typical permissions (everything is writable except <blacklist> instead of everything is not writable except <whitelist>). –  abarnert Nov 19 '12 at 23:58
THANKS really helped. I was actually making the files on desktop than in the home directory... –  user1837259 Nov 20 '12 at 0:30
@user1837259: The desktop is fine. It's %HOME%\desktop on modern (2000 or later) Windows, and either ~/Desktop, ~/desktop, ~/.desktop, or something similar on just about any modern *nix system. (The former is what OS X uses, and I believe the default with xdg.) This means you own it, and it's part of your home directory, so you can put anything you want there. (Of course it can get a bit messy to look at, but that's a separate issue.) –  abarnert Nov 20 '12 at 0:41
add comment

Your Answer


