prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Another AB guide request - installing an uncommon program

Sat May 12, 2012 9:00 pm

Ok, there's a Python program that I'd like to run on the Pi - it's probably a bit of a collector's item and so isn't in the main repository AFAICS. But it does seem to be in something called github (not that I really know what that is :) ). I guess this is a new-user question that could be asked often so if anyone could outline what's required to download and install such a program, I'd be hugely grateful, and maybe others too in the future. Steps needed would be (all for Pi Debian):

1. How to download the program from the shell.
2. I guess it's likely to be compressed, so how to uncompress
3, How then to install it.
4. Um, that's probably it. (Oh, except that it would be handy to know - just out of curiosity - where user programs live in the file tree. Presumably not in /home otherwise they wouldn't be available to other users (?). And I've got a follow-up question about where eg program-specific input and output files might be expected to be located, but maybe I'll leave that until I've got the program installed and tried to run it.)

User avatar
stevepdp
Posts: 285
Joined: Fri Oct 28, 2011 7:41 am
Contact: Website Twitter

Re: Another AB guide request - installing an uncommon progra

Sat May 12, 2012 11:05 pm

Use the program "wget" to download files from the shell. It's incredibly simple to use:

Code: Select all

wget http://www.raspberrypi.org/favicon.ico
Use the -c switch for larger files, as it will allow for download resuming.

Decompressing files depends on the format of the archive. "unzip" will unzip zip most files, "tar zxvf archive.tar.gz" will usually unpack gzipped tarballs quite happily. "unrar" will extract most rar archives. Read the man pages for each for more details.

Installation again depends on the program. Refer to it's README or INSTALL files for installation instructions. Sometimes it's simply a case of giving it executable permissions with "chmod +x filetoexecute" and then executing it "./iwanttolaunchthisprogram". Let us know the name and location of the program you're talking about and we can be more specific ;-)

With regards to how files are organised in the Raspberry Pi operating systems, try looking up things like the FHS and Debian Filesystem Hieracy Standard, it's too much to explain here ;-)

prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 7:46 am

OK thanks, but a couple of follow-ups:
I don't really understand what github is. It's obviously a source (is repository the right word or not?) of programs, but are there some special rules for interacting with it?
Specifically, if I try:
wget https://github.com/cmcginty/PyWeather.git
which is the program I'm after then I get a permissions error. Not too surprising perhaps since it's https. So I try --no-check-certificate (which actually spills over on to a second line at the shell prompt - does this matter?) but I get a 404 error even though AFAICS that is the correct URL for the target program.

Then on the directory location aspect: I'm not seeking a complete understanding of the Linux directory structure at this stage - my question is much simpler. On a Windows PC the default location for any downloads that I request is my \Downloads folder. And then if I install a program, its default will be to create a folder for itself within \Program Files and locate itself there. When running it will use a special dedicated folder location that it creates nested within my user area for any working files that it needs to create.
The question is simply what are the Debian equivalents for these three locations?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26046
Joined: Sat Jul 30, 2011 7:41 pm

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 7:55 am

GITHUB is a online source code control system using the GIT program to access it (so, like online subversion, or SourceSafe, or Perforce or...). So you can download the source code from GITHUB using the git application, using something like git clone http:\[insert location here]. There should be instructions on the github page on what you need to do.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 8:04 am

jamesh wrote:There should be instructions on the github page on what you need to do.
Not obviously - to me at least. There are download buttons which work OK (eg in Windows), but I'm trying to understand how I would get a download to work directly from within the Pi shell.
So does wget not work directly with github programs? Or does it need to use the git protocol rather than http/https, ie git://etc ?
Is git a tool that's installed in Pi Debian by default - you seem to be suggesting that a git command should be used instead of wget?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26046
Joined: Sat Jul 30, 2011 7:41 pm

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 8:12 am

Yes, you should use git to download stuff from github. Not sure wget would work.
Githib does have pretty good instructions - I have to use them when I download stuff. Think there should be a link from the home page of the project .
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 8:34 am

OK an update:
I guessed that git is not included in the Debian Pi distribution so:

Code: Select all

sudo apt-get install git
which seemed to work.
Then, still not being sure of the correct github syntax (I'm sure that there is good help at github, it's just that it seems to be tailored to development interactions with github rather than a simple download) I tried:

Code: Select all

git clone http://github.com/cmcginty/PyWeather.git
which again seemed to work without errors. However, having seemingly made some good progress, I'm now back to one of my original questions:
The download seems to have worked, and a set of files and folders apparently unpacked automatically and placed in a PyWeather folder in my user area.Is this really where they should live permanently? (I suspect in principle they could live anywhere, what I'm asking is whether this would be the default/standard location for new programs?)

prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 8:39 am

And then a further follow-up question:
In my new download, I can see various files like CHANGELOG.txt, COPYING.txt, INSTALL.txt and README all of which look like I should read them. but if I try eg print INSTALL.txt or print README then I just get errors. Are these special files that need to be accessed in a special way? (This could maybe be a Python question rather than a Linux one - I'm not sure at this stage.)

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26046
Joined: Sat Jul 30, 2011 7:41 pm

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 9:01 am

Generally, stuff downloaded from github is source code, not a finished installable program, so you need to do some work to get the source code installed.

You are on the right track with the readme's etc, but can you post what the errors you are seeing are?

To display a file, you can do 'cat [filename]'. You can do

cat [filename] | more

to get it to stop at the end of eachpage instead of whizzing past. Or you can

cat [filename] | less

which give you scrolling up and down.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 9:18 am

jamesh wrote:Generally, stuff downloaded from github is source code...
Is there any real distinction for a (non-compiled) Python program, which is what I'm pulling down? (other than the code possibly being a debug version or a work in progress rather than a polished final version - which I don't think is the case here)
To display a file, you can do 'cat [filename]'.
Sorry - I obviously know so little about Linux that I'm just plain using the wrong command. I was thinking that I should just be able to display/print what is apparently tagged as a text file, but apparently not. Cat works just fine - thanks.

amacater
Posts: 9
Joined: Sun Apr 15, 2012 7:29 pm

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 10:20 am

As others have said: sudo apt-get install git will install git.

git clone git://github.com/zakhomuth/pyweather.git will get you the command line PyWeather client - but it's Python source.

git clone will "take a copy" of whatever repository it is on github and put it into the directory you're currently in.

When you log in, you're normally put at your home directory - so for me, that would be /home/amacater - and if you git clone to that directory you'll get the copy there. Possibly best to make a directory pycode

mkdir pycode

inside your home directory. Change to that directory -

cd pycode

- then run the git code above.

cat is a way to list any text file -to screen you can pipe it through less to get a paged display.

cat README.txt | less

or use the command less by typing

less README.txt

Once you've got your Python code: change into the directory - cd /home/amacater/pycode/pyweather - and follow the instructions in the README.

Quite a few progams will install in /usr/local/lib<programname> (libraries) or /usr/local/bin/<programname> (binaries/programs you can run). /usr/local is in the user path so you should then be able to run

pyweather

or whatever.

There is a good Debian handbook just published and freed under GPL / CC-By-SA : the authors have just spent several months translating it and would greatly appreciate donations / payment for the paper version but this is not mandatory.

http://debian-handbook.info/2012/the-debian-administrators-handbook-is-available/

Steady_Bear
Posts: 110
Joined: Sat Jan 14, 2012 12:06 pm

Re: Another AB guide request - installing an uncommon progra

Sun May 13, 2012 12:34 pm

Hi,
Just a couple quite notes:

less filename
is a slightly more simplified form of 'cat filename | less' same goes for 'more'.

Just to explain these commands, 'cat' will dump information from any file or any device under '/dev/' (you'd probably not want to be playing with the '/dev/' area until you know what you're playing with). It works well with devices because it just does an unformatted dump of data.
Both 'less' and 'more' offer the user some flexibility when reading large blocks of text. Such as scrolling around to read text and also search for text ('/' to activate search) 'q' will quit. I'd recommend using 'less' over 'more' as it's a more advanced (newer) system.
If you use the pipe '|' symbol it is telling the first piece of software to put its output through the second piece of software. Great if the first piece of software actually processes data.

Hitting 'shift-page up' or 'shift-page down' under a terminal will scroll up and down through the old output.


As to where stuff goes, there are 4 standard options:
1) It was installed from the package manager, so it goes under the standard system layout (bits scattered between /lib /bin /lots-more :) ).
2) It's under /home/user and you're happy with that (ie only that user wants the software).
3) /opt - this seems to be a common dumping ground for mostly self contained programs. Especially popular with modern commercial stuff. I'm not aware of any formal standard as to how it's laid out, not that it would really matter.
4) /usr/local - this pre-dates /opt and does have a standard layout. If there is only one file involved in your finished product (ie the python script itself) then it should really go into /usr/local/bin.

So, if there is only the one file to move, option 4 is the obvious one. If there are lots of files to move, and you're not looking to learn too much about /usr/local's layout, then option 3 is the best one. You can always revert to option 4 from option 3 at a latter date after gaining some more experience.


Program output is down to how the coder made the software work ;). Typically it will go to wherever you are when you run the program: ie if you're in /home/user and you run a piece of software in /usr/local/bin, then output will go to /home/user. Not guaranteed though.

Return to “Beginners”