Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ImportError: No module named turtle [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
cwc
Veteran
Veteran


Joined: 20 Mar 2006
Posts: 1112
Location: Tri-Cities, WA USA

PostPosted: Mon May 19, 2008 4:27 am    Post subject: ImportError: No module named turtle [SOLVED] Reply with quote

I'm trying to mess around with turtle graphics with Python just to find out how it works
and decide if a I want to implement it into a Linux/Java course I teach.

Heres the error:
>>> import turtle
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named turtle

Any ideas?

I'm trying to run this simple code:
Code:

import turtle

def polygon(n):
    for side in range(n):
        turtle.forward(100)
        turtle.left(360.0/n)

# (comment) and then try things like these...
polygon(3)
polygon(4)
polygon(8)


_________________
Without diversity there can be no evolution:)


Last edited by cwc on Tue May 20, 2008 4:59 am; edited 1 time in total
Back to top
View user's profile Send private message
Elbar Thera
n00b
n00b


Joined: 15 May 2008
Posts: 60

PostPosted: Mon May 19, 2008 5:29 am    Post subject: Reply with quote

Hi there,

i have just tested a turtle import on my system, using python 2.4.4, and it works without problem. A quick look into the docs shows, that the turtle module depends on Tk. Do you have Tk installed? That's the only guess i can come up with :)

Greets,
Elbar
Back to top
View user's profile Send private message
alistair
Retired Dev
Retired Dev


Joined: 15 Jul 2005
Posts: 869

PostPosted: Mon May 19, 2008 8:47 am    Post subject: Reply with quote

Lets start with these questions.

1) What version of python do you have.

2) Where is turtle installed
_________________
______________
Help the gentoo-java project. Visit Gentoo Java Project

what good are admin powers if you don't abuse them for personal gain - mark_alec
Back to top
View user's profile Send private message
cwc
Veteran
Veteran


Joined: 20 Mar 2006
Posts: 1112
Location: Tri-Cities, WA USA

PostPosted: Mon May 19, 2008 11:33 am    Post subject: Reply with quote

alistair wrote:
Lets start with these questions.

1) What version of python do you have.

2) Where is turtle installed

First of all Thank you!

# 1 > python
Python 2.4.4 (#1, Apr 10 2008, 19:17:57)
[GCC 4.1.1 (Gentoo 4.1.1-r3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# 2 > I thought turtle was an default package of Python. I did "emerge tcl tk"
tma ~ # python -V
Python 2.4.4

$ locate turtle
/var/cache/edb/dep/usr/portage/kde-base/kturtle-4.0.3
/var/cache/edb/dep/usr/portage/kde-base/kturtle-4.0.2
/var/cache/edb/dep/usr/portage/kde-base/kturtle-3.5.9
/var/cache/edb/dep/usr/portage/kde-base/kturtle-3.5.8
/home/cwc/ppython/backup/turtle.py~ # ????
/home/cwc/ppython/backup/turtle.pyc #???????????????
/home/cwc/ppython/turtle_2.py #my code
/home/cwc/ppython/turtle_1.py #my code
/home/cwc/Desktop/xturtle.zip #another form of turtle I have not tried
/usr/lib/openoffice/program/python-core-2.3.4/lib/lib-tk/turtle.py
/usr/portage/metadata/cache/kde-base/kturtle-4.0.3
/usr/portage/metadata/cache/kde-base/kturtle-4.0.2
/usr/portage/metadata/cache/kde-base/kturtle-3.5.9
/usr/portage/metadata/cache/kde-base/kturtle-3.5.8
/usr/portage/kde-base/kturtle
/usr/portage/kde-base/kturtle/metadata.xml
/usr/portage/kde-base/kturtle/kturtle-3.5.9.ebuild
/usr/portage/kde-base/kturtle/kturtle-4.0.3.ebuild
/usr/portage/kde-base/kturtle/kturtle-4.0.2.ebuild
/usr/portage/kde-base/kturtle/kturtle-3.5.8.ebuild
/usr/portage/kde-base/kturtle/Manifest
/usr/portage/kde-base/kturtle/ChangeLog
_________________
Without diversity there can be no evolution:)
Back to top
View user's profile Send private message
cwc
Veteran
Veteran


Joined: 20 Mar 2006
Posts: 1112
Location: Tri-Cities, WA USA

PostPosted: Mon May 19, 2008 11:35 am    Post subject: Reply with quote

Elbar Thera wrote:
Hi there,

I have just tested a turtle import on my system, using python 2.4.4, and it works without problem. A quick look into the docs shows, that the turtle module depends on Tk. Do you have Tk installed? That's the only guess i can come up with :)

Greets,
Elbar


Thanks for the line!

My I see your code please?
This is what I tried
Code:

import turtle

def polygon(n):
    for side in range(n):
        turtle.forward(100)
        turtle.left(360.0/n)

# (comment) and then try things like these...
polygon(3)
polygon(4)
polygon(8)



These are my equery's
I'm not sure what to do with the backtraces?
Code:

equery uses python
[ Searching for packages matching python... ]
[ Colour Code : set unset ]
[ Legend : Left column  (U) - USE flags from make.conf              ]
[        : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-lang/python-2.4.4-r9 ]
 U I
 + + berkdb       : Adds support for sys-libs/db (Berkeley DB for MySQL)
 - - bootstrap    : !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used during original system bootstrapping [make stage2]
 - - build        : !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1]
 - - doc          : Adds extra documentation (API, Javadoc, etc)
 - - elibc_uclibc : <unknown>
 - - examples     : Install examples, usually source code
 + + gdbm         : Adds support for sys-libs/gdbm (GNU database libraries)
 + + ipv6         : Adds support for IP version 6
 + + ncurses      : Adds ncurses support (console display library)
 - - nocxx        : Disable support for C++ (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)
 - - nothreads    : Disable threads (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)
 + + readline     : Enables support for libreadline, a GNU line-editing library that almost everyone wants
 + + ssl          : Adds support for Secure Socket Layer connections
 - - tk           : Adds support for Tk GUI toolkit
 - - ucs2         : Enable byte size 2 unicode (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)

tma ~ # equery uses tk   
[ Searching for packages matching tk... ]
[ Colour Code : set unset ]
[ Legend : Left column  (U) - USE flags from make.conf              ]
[        : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-lang/tk-8.4.18 ]
 U I
 - - debug   : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml
 - - threads : Adds threads support for various packages. Usually pthreads

tma ~ # equery uses tcl
[ Searching for packages matching tcl... ]
[ Colour Code : set unset ]
[ Legend : Left column  (U) - USE flags from make.conf              ]
[        : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-lang/tcl-8.4.18 ]
 U I
 - - debug   : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml
 - - threads : Adds threads support for various packages. Usually pthreads


_________________
Without diversity there can be no evolution:)
Back to top
View user's profile Send private message
Elbar Thera
n00b
n00b


Joined: 15 May 2008
Posts: 60

PostPosted: Mon May 19, 2008 12:17 pm    Post subject: Reply with quote

The code i'm using is even simpler than yours (although i'm using ipython):

Code:
import turtle

turtle.demo()


I think the equery shows the problem. Your python was not compiled with tk support, at least that's what i'm reading out of it. Here is the output on my computer:

Code:
equery uses python
[ Searching for packages matching python... ]
[ Colour Code : set unset ]
[ Legend : Left column  (U) - USE flags from make.conf              ]
[        : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-lang/python-2.4.4-r9 ]
 U I
 + + berkdb       : Adds support for sys-libs/db (Berkeley DB for MySQL)
 - - bootstrap    : !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used during original system bootstrapping [make stage2]
 - - build        : !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1]
 + + doc          : Adds extra documentation (API, Javadoc, etc)
 - - elibc_uclibc : <unknown>
 + + examples     : Install examples, usually source code
 + + gdbm         : Adds support for sys-libs/gdbm (GNU database libraries)
 + + ipv6         : Adds support for IP version 6
 + + ncurses      : Adds ncurses support (console display library)
 - - nocxx        : Disable support for C++ (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)
 - - nothreads    : Disable threads (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)
 + + readline     : Enables support for libreadline, a GNU line-editing library that almost everyone wants
 + + ssl          : Adds support for Secure Socket Layer connections
 + + tk           : Adds support for Tk GUI toolkit
 - - ucs2         : Enable byte size 2 unicode (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)


As you can see, the only difference are the two tiny little plus-signs in front of the Tk GUI toolkit support =)

Greets,
Elbar
Back to top
View user's profile Send private message
cwc
Veteran
Veteran


Joined: 20 Mar 2006
Posts: 1112
Location: Tri-Cities, WA USA

PostPosted: Mon May 19, 2008 7:14 pm    Post subject: Reply with quote

Thanks Elbar,

Thanks! I tried to set tk in with
dev-lang/python tcltk in add a line to /etc/portage/package.uses:
this did not work!
I found this on another thread.

This did work:
* USE="tk" in /etc/make.conf

# Recompile python
emerge --newuse python

I'm ready for the turtle. I'd like to do some recursive designs to model recursion!

Thanks,
cwc
_________________
Without diversity there can be no evolution:)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum