16.01.2014 Views

Beginning Python - From Novice to Professional

Beginning Python - From Novice to Professional

Beginning Python - From Novice to Professional

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4 CHAPTER 1 ■ INSTANT HACKING: THE BASICS<br />

If there is no <strong>Python</strong> interpreter installed, you will probably get an error message similar <strong>to</strong><br />

the following:<br />

bash: python: command not found<br />

In that case, you have <strong>to</strong> install <strong>Python</strong> yourself, as described in the following sections.<br />

Linux with RPM<br />

If you are running a Linux distribution with the RPM package manager installed, follow these<br />

steps <strong>to</strong> install the <strong>Python</strong> RPM packages:<br />

1. Go <strong>to</strong> the download page (refer <strong>to</strong> steps 1 and 2 in the instructions for installing <strong>Python</strong><br />

on a Windows system).<br />

2. Follow the link with the most recent version number, such as “<strong>Python</strong> 2.4.” (Don’t<br />

choose a link with the word “sources” in it.) Chances are that this link will be found early<br />

on the page. For <strong>Python</strong> 2.4, you could simply go <strong>to</strong> the URL http://www.python.org/<br />

2.4. Follow the instructions for Fedora users: follow the link “RPMs.”<br />

3. Download all the binary RPMs. S<strong>to</strong>re them in a temporary location (such as ~/rpms/<br />

python).<br />

4. Make sure you are logged in as system administra<strong>to</strong>r (root) and are currently in the<br />

direc<strong>to</strong>ry where you s<strong>to</strong>red the RPMs. Make sure there are no other RPMs in this<br />

direc<strong>to</strong>ry.<br />

5. Install the packages by executing the command rpm --install *.rpm. If you already<br />

have an older version of <strong>Python</strong> installed and wish <strong>to</strong> upgrade, you should instead use<br />

rpm --upgrade *.rpm.<br />

■Caution The preceding command installs all the RPM files in the current direc<strong>to</strong>ry. Make sure that you<br />

are in the correct direc<strong>to</strong>ry and that it only contains the packages you want <strong>to</strong> install. If you want <strong>to</strong> be more<br />

careful, you can specify the name of each package separately. For more information about RPMs, check out<br />

the man page.<br />

You should now be able <strong>to</strong> run <strong>Python</strong>. On occasion, you may run in<strong>to</strong> some unresolved<br />

dependencies—you may lack other RPM packages needed <strong>to</strong> install <strong>Python</strong>. To locate these<br />

packages, visit a search facility such as http://www.rpmfind.net.<br />

Sometimes a binary RPM package designed for one Linux distribution (for example, Red<br />

Hat Linux) may not work smoothly with another (for example, Mandrake Linux). If you find<br />

that the binary package is giving you grief, try downloading a source RPM instead (with a name<br />

like packagename.src.rpm). You can then build a set of binary packages tailored for your system<br />

with the command<br />

rpm --rebuild packagename.src.rpm

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!