Installing a Python Package

A forum for general discussion of the Python programming language.

Installing a Python Package

Postby Magolor » Mon Aug 12, 2013 8:04 pm

I've been using the book "Think Python" to help teach me the Python programming language, and it's been pretty great so far. However, at the start of Chapter 4 the author talks about installing a package he created called 'Swampy' which houses several modules to help teach the readers subjects like object-oriented programming and procedural interface design. Here's a link to the page for Swampy.

I clicked "Install Swampy," followed the directions for Windows users, and made sure that I had Tkinter. (which I did) The problem comes down to installing the package. I tried following what the author said about making sure I'd be able to run Python from the Command Prompt first, but when doing what he said (along with this video tutorial) the command prompt still wouldn't recognize me typing out 'python'. Because it can't recognize it, it looks like I won't be able to install the package. These would be the next steps to install the package.

"Right click the file at the bottom of the page and save the file in the site-packages folder (ex: C:\Python23\Lib\site-packages).

Next, right click the .tar.gz file in the folder and click "Extract Here" to extract the file in the folder. The file should create a "swampy-2.1.1" folder with all Swampy files."

So if anyone knows what I'm doing wrong when trying to add the Python27 folder to the search path, I'd greatly appreciate it.
User avatar
Posts: 2
Joined: Mon Aug 12, 2013 7:40 pm

Re: Installing a Python Package

Postby tnknepp » Wed Aug 14, 2013 4:14 pm

I assume you put Python in the Windows path. Try re-starting your machine then run the install. If that does not work, provide more detail with what you have tried and we can go from there.
Python: 2.7 via Anaconda
Numpy: 1.7
Pandas: 0.11
OS: Windows 7
IDE: Spyder/IPython
User avatar
Posts: 153
Joined: Mon Mar 11, 2013 7:41 pm

Re: Installing a Python Package

Postby Magolor » Fri Aug 16, 2013 5:40 pm

Thanks, I did try restarting but got the same problem as before. I'll try editing this post later with more details about what I've tried so far.

EDIT: Alright, here's a more detailed description of what I did and the problems I've faced.

Recently I have begun reading through a book called "Think Python" to teach myself how to learn the Python programming language. I've already installed Python 2.7.5 with both IDLE and the command line, and have been able to program multiple things. In the fourth chapter of the book, the author starts getting into something called "packages," which as he describes, is a collection of modules. The package he wants the reader to install is one called 'Swampy', which he created. The page for it can be found in the link below. (the same link I posted in the O.P.)

According to the site, there are five components, or modules within Swampy. The author starts off by focusing on one of the modules, called TurtleWorld, and mentions two ways to import to the module into Python. Here's what he says:

If Swampy is installed as a package on your system, you can import TurtleWorld like this:

from swampy.TurtleWorld import *

If you downloaded the Swampy modules but did not install them as a package, you can either work in the directory that contains the Swampy files, or add that directory to Python's search path. Then you can import TurtleWorld like this:

from TurtleWorld import *

It doesn't really matter which method I use so far as I know, so I guess either way would work. However, since I couldn't find any individual installation links for each module and installing them as one from Swampy seems like a better choice anyway, I decided to click 'Install Swampy', which can be found at the top of the Swampy website. Since I'm not using Python 3 and my operating system is Windows (7), I scrolled down (through the page that the 'Install Swampy' button linked me to) past Python 3, Linux, and Macintosh, down at the bottom where it says 'Windows'. Now, I've already installed Python, but it mentions running it from the command prompt, so I tried doing that just in case. Before I get into all of that though, I'll just say that for the second part of the 'Windows' section where it talks about installing Tkinter, I did what it said, typing...

import Tkinter the Python prompt inside IDLE, and because I received no error messages, that should mean that Tkinter is already installed. (Since on the page, in the Windows section, it says that if I already have Tkinter, Python will not print an error message, which it didn't here.)

So since I have Python and Tkinter, but not Swampy, I went back to the 'Install Python' part of the Windows section, which says this:

To run Python from the Command Prompt, you need to add the folder that contains Python to the list of folders Windows searches for commands. The name of the folder is probably C:\Python26 or C:\Python27.

To add this folder to the search path, select Control panel -> system -> advanced -> Environmental Variables -> system variables -> Path. Add C:\Python26 or C:\Python27 to the end of the list (with a semi-colon as a separator).

Now if you restart the command window, you should be able to type python at the prompt and launch Python.

Alright, so here's what I did. I went to the Start menu, and searched for C:\Python27. When I did, a folder popped up which said "Python27." Having made sure it was there and seeing what it looked like, I went back to the Start Menu, and hit the buttons it mentioned. At the start menu, I clicked on "Control Panel," clicked on "System and Security" which is where "System" was, I clicked on that, and then I went to "Advanced system settings."Once doing so, a window popped up, which looked like this:


Continuing to follow what the author said, I hit "Environmental Variables," and another window popped up. Under the 'System Variables' box, I clicked 'Path' like the author said to, and then pressed 'Edit.' In the edit window, he said to add C:\Python26 or C:\Python27 to the end of the list (with a semi-colon as a separator). So, in the 'Variable value:' box, I added :C:\Python27 after the end, which was WirelessCommon\

After doing this, I pressed 'OK' to exit out of the "Edit System Variable" window, pressed 'OK' to exit out of the "Environment Variables" window, and then 'OK' again to exit out of the "System Properties" window. Once I did that, I started up "Command Prompt" (assuming that's what he meant by "command line") and I typed in the word python like he mentioned. However, instead of launching Python like it should have, the Command Prompt gave me the following message.

'python' is not recognized as an internal or external command,
operable program or batch file.


So in short, the problem I'm facing is that it looks like I can't add the C:\Python27 folder to the Windows search path since the Command Prompt won't open this. Because of that, it looks like I'll have trouble installing the Python package 'Swampy' or any other future packages. (unless the steps to getting it in the search path isn't actually required for installing packages/modules. If so, my mistake, I'm still a rookie at this. xP)
User avatar
Posts: 2
Joined: Mon Aug 12, 2013 7:40 pm

Return to General Discussions

Who is online

Users browsing this forum: Google [Bot] and 6 guests