Hummus
Hummus

Reputation: 365

Installing Swampy for Python 3

I am currently running Python 3.2 on my computer and need to install Swampy for a book I am reading. Reading many pages and pages on a tutorial has left me further confused. I have downloaded 'swampy1.4'. I am trying to do this by following the set of instructions on this page- http://www.instructables.com/id/How-to-install-Python-packages-on-Windows-7/.

When trying to change directories to simplejson2.6.1 (I have an updated version of this software to the page) I am getting this error- 'The system could not find the specified path.'

Could anyone tell me where I am going wrong? It would be much appreciated.

Upvotes: 0

Views: 4474

Answers (4)

AndreBam_
AndreBam_

Reputation: 21

To get swampy:

Doing a pip install won't install swampy for python 3.

This method should work: Download the source code from here. Unzip the file to the directory you want. You're going to have to remember this directory.

Next, create a swampy.txt file in the following directory:

C:/Python32/Lib/site-packages

This assumes that you installed python in C:/Python32. You should modify this depending on where you installed python.

Remember the directory in which you unzipped the source code? Type the full path to the source code folder, not the directory you unzipped it into, into swampy.txt. After this, change the extension of the text file you just created from .txt to .pth. What this does is adds the source code to the search path of python.

You should be good to go now.

Upvotes: 2

Tom Wilson
Tom Wilson

Reputation: 698

The link is correct but the explanation is vague even for an experienced Windows developer. It assumes too much knowledge of the Python installation process IMO.

e.g. "The simplest way to use this code is to unzip it in your home directory, cd into the unzipped directory and work there." What is meant by 'home directory'? Then there is a reference to an 'unzipped directory', which I presume means the home directory. The change of name is confusing.

Nevertheless, say one unzips to C:\Python33\lib\swampy-2.1, and works from there. Whatever this means? I can only presume it means save your code in the swampy 'home directory'. It is not best practice to save your python code in a library directory. I use \dev\python\test\ but then

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import swampy
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import swampy
ImportError: No module named 'swampy'

However, if the swampy directory is simply renamed to swampy (from swampy-2.1) then all is OK!

>>> import swampy
>>> from swampy.Gui import *
>>> g=Gui()
>>> g.title('Swampy.GUI')
>>> g.mainloop()

FYI this is my path (my dev drive is E: rather C:)

E:\Python33\Lib>path
PATH=E:\Python33\;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\System32\Wbem;E:\Program Files\Microsoft SQL Server\100\Tool
s\Binn\;E:\Program Files\Microsoft SQL Server\100\DTS\Binn\;E:\WINDOWS\system32\WindowsPowerShell\v1.0;E:\Program Files\
Microsoft\Web Platform Installer\;E:\Program Files\Microchip\xc8\v1.21\bin;E:\Program Files\GtkSharp\2.12\bin

and I don't have a PYTHONPATH environment variable as suggested by other posts.

Upvotes: 0

user1919235
user1919235

Reputation: 520

You can now actually use swampy from source with Python 3.2. Please see http://www.greenteapress.com/thinkpython/swampy/install.html. It clearly says:

Swampy for Python 3 is not available as a package. But the source code is available in a zip file: Swampy source for Python 3: swampy-2.1.python3.zip

I tried to use it under Windows Vista following the instructions on the web page, and at least importing TurtleWorld worked just fine.

Upvotes: 0

utapyngo
utapyngo

Reputation: 7136

Quote from Swampy Installation Instructions:

You should see something like this:

Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
>>>

If so, you have Python. If the version number starts with 2, you have Python 2, which is the version of Python used in Think Python. If the version number starts with 3, you have Python 3. You will not be able to use Swampy with Python 3.

I suppose you want Swampy just to learn Python. In this case I would recommend you the official Python 3 tutorial.

If you want to continue reading the book don't be afraid of installing Python 2.7.3. Multiple versions of Python can coexist even on Windows assuming that you correctly setup the PATH variable.

There is also a newer version of Swampy (2.1.1).

Upvotes: 0

Related Questions