| 
 | 12 years ago 3 | 
 Installing the Python Package "Swampy"
 
 See http:\\www.thinkpython.com for more information.
 
 In the book 'Think Python' some exercises use a module called Swampy. The description on the website uses installers PIP and Easy Install to deal with the installation package, but they don't appear in  LinuxMint MAYA. I couldn't get any of the GUI installers in MAYA to work with this package so I tried doing it by command line in a terminal window.
 Step one, open a terminal window.
 
 I had downloaded the Swampy package as a .gz.tar file and extracted it to my home directory. In the terminal, I checked that it was there.
 
 jim@PAN ~ $ ls
 2008-04-23  Documents  Dropbox  Pictures  swampy-2.1.1  Videos
 Desktop     Downloads  Music    Public    Templates
 
 
 It was, so I switched to the package directory and confirmed the contents. There's a file "setup.py" that's probably installs the module!
 
 jim@PAN ~ $ cd swampy-2.1.1
 jim@PAN ~/swampy-2.1.1 $ ls
 CHANGES.txt  LICENSE.txt  PKG-INFO  README.txt  setup.py  swampy
 
 
 After playing a bit with the file "setup.py" I found it needs some additional commands.
 
 jim@PAN ~/swampy-2.1.1 $ python setup.py --help
 Common commands: (see '--help-commands' for more)
 
   setup.py build      will build the package underneath 'build/'
   setup.py install    will install the package
 
 (There is more than this, the remainder has been snipped for clarity.)
 
  
 The commands "build" and "install" look like they're the keys. So lets try "build".
 
 jim@PAN ~/swampy-2.1.1 $ python setup.py build
 running build
 running build_py
 creating build
 creating build/lib.linux-i686-2.7
 creating build/lib.linux-i686-2.7/swampy
 copying swampy/Gui.py -> build/lib.linux-i686-2.7/swampy
 <-----  text snipped out ----->
 
 
 So what has been built? There's now a new directory called "build".
 
 jim@PAN ~/swampy-2.1.1 $ ls
 build  CHANGES.txt  LICENSE.txt  PKG-INFO  README.txt  setup.py  swampy
 
 
 The next step is to try "install".
 
 jim@PAN ~/swampy-2.1.1 $ python setup.py install
 running install
 running build
 running build_py
 running install_lib
 creating /usr/local/lib/python2.7/dist-packages/swampy
 error: could not create '/usr/local/lib/python2.7/dist-packages/swampy': Permission denied
 
 
 Permission? Oh yes, it wants to write data and create directories. Time for Super User!
 
 
 jim@PAN ~/swampy-2.1.1 $ sudo python setup.py install
 [sudo] password for jim:
 running install
 running build
 running build_py
 running install_lib
 creating /usr/local/lib/python2.7/dist-packages/swampy
 copying build/lib.linux-i686-2.7/swampy/Gui.py -> /usr/local/lib/python2.7/dist-packages/swampy
 copying build/lib.linux-i686-2.7/swampy/World.py -> /usr/local/lib/python2.7/dist-packages/swampy
 <----- text snipped out ----->
 
 
 This looks promising! OK open a Python GUI and see if modules can be imported from Swampy
 
 >>> import swampy.TurtleWorld
 >>>
 
 No error messages means it's working.
 
 
 Just in case, I finished off by running the setup-clean routine. Not sure what there is to be cleaned up, but I figured it's good practice.
 
 jim@PAN ~/swampy-2.1.1 $ python setup.py clean
 running clean
 jim@PAN ~/swampy-2.1.1 $
 
 
 After all this, the Python scripts using TurtleWorld run perfectly.