1

I need to install graphics.py for class. How do I do that, and how do I install other Python modules?

4

3 Answers 3

1

Here is a guide:

Start at Zelle’s Python page at http://mcsp.wartburg.edu/zelle/python/.

The graphics module is listed as *graphics.py. RIGHT-CLICK on the link and then select >Save Link As

On a PC save the link in C:\Python31\Lib\site-packages

On a Mac save the link in

/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages/

On Ubuntu save the link in

/usr/lib/python3/dist-packages

5
  • I'm on Ubuntu 14.04 I tried to copy and paste it in usr/local/lib/python3.4/site-packages and usr/local/lib/python3.4/dist-packages
    – jwyer174
    Sep 5, 2014 at 18:39
  • Okay so then what happened? Sep 5, 2014 at 18:41
  • When I use eclipse it doesn't import graphics
    – jwyer174
    Sep 5, 2014 at 18:47
  • @user3485632 have you tried running the program without Eclipse? Eclipse is really only decent for Java. Sep 5, 2014 at 18:48
  • I've tried in Canopy aswell and got this error message: ImportError: libpng16.so.16: cannot open shared object file: No such file or directory
    – jwyer174
    Sep 5, 2014 at 18:56
0

You need to copy your graphics.py copy in a python3 imported path:

sudo cp graphics.py /usr/local/lib/python3.4/dist-packages/

Then the only dependency to install is Tkinter:

sudo apt-get install python3-tk

To check that you can import your new module start a python3 interpreter like this:

$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from graphics import *
>>>

You should not see any ImportError message.

5
  • I got two import errors ImportError: No module name '_tkinter' and ImportError: No module name 'Tkinter'
    – jwyer174
    Sep 5, 2014 at 19:35
  • I got this error when a run a command in python (2.x). Please be sure to run your script with a python3 interpreter otherwise install python-tk for python2.x: sudo apt-get install python-tk Sep 5, 2014 at 19:43
  • I am using the python 3 interpreter and both versions are installed, I also have this Traceback (most recent call last): File "/usr/local/lib/python3.4/site-packages/graphics.py", line 159, in <module> import tkinter as tk File "/usr/local/lib/python3.4/tkinter/__init__.py", line 38, in <module> import _tkinter # If this fails your Python may not be configured for T
    – jwyer174
    Sep 5, 2014 at 19:55
  • and Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/site-packages/graphics.py", line 161, in <module> import Tkinter as tk ImportError: No module named 'Tkinter'
    – jwyer174
    Sep 5, 2014 at 19:56
  • When I use python 2.7 I don't get any errors and inside python2.7/dist-packages I have virtualenv-1.11.6 and inside python3.4/dist-packages I only have graphics.py
    – jwyer174
    Sep 5, 2014 at 20:08
-2

to correct No module named Tkinter and _tkinter

sudo apt-get install tk-dev
cd /Python3.4.1 
./configure
make
sudo make install
2
  • 1
    -1 for "out of the blue" upstream Python local build. Why is it needed to compile your own Python here? Please clarify.
    – gertvdijk
    Sep 15, 2014 at 11:42
  • reinstall python3 really works on my Ubuntu 14.04. I think .configure and install make python3 be configured for Tkinter
    – user340107
    Oct 19, 2014 at 3:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .