<div dir="ltr"><div><div>Hola:<br><br></div>Estaba haciendo unos scripts el otro día con python3 y al querer usar el modulo turtle para un ejemplo tuve errores al ejecutarlo.<br><br></div>Mi primer idea fue que no tenía instalado bien el modulo o algo por lo que no podía ejecutar correctamente el script en cuestión que es el siguiente:<br>
<br># centipede.py <br><br>from turtle import *<br><br>def centipede(length, step, life):<br> penup()<br> theta = 0<br> dtheta = 1<br> for i in range(life):<br> forward(step)<br> left(theta)<br> theta += dtheta<br>
stamp()<br> if i > length:<br> clearstamps(1)<br> if theta > 10 or theta < -10:<br> dtheta = -dtheta<br> if ycor() > 350:<br> left(360)<br><br>def main():<br>
setworldcoordinates(-400, -400, 400, 400)<br> centipede(14, 10, 200)<br> exitonclick()<br><br>main()<br clear="all"><div><div><div><br></div><div>Al ejecutar dicho script con python3 obtengo el siguiente error:<br>
<br>aradnix@Melania-V5-131:~/Documentos/Python 3$ python3 centipede.py <br>Traceback (most recent call last):<br> File "/usr/lib/python3.4/tkinter/__init__.py", line 39, in <module><br> import _tkinter<br>
ImportError: No module named '_tkinter'<br><br>During handling of the above exception, another exception occurred:<br><br>Traceback (most recent call last):<br> File "centipede.py", line 3, in <module><br>
from turtle import *<br> File "/usr/lib/python3.4/turtle.py", line 107, in <module><br> import tkinter as TK<br> File "/usr/lib/python3.4/tkinter/__init__.py", line 41, in <module><br>
raise ImportError(str(msg) + ', please install the python3-tk package')<br>ImportError: No module named '_tkinter', please install the python3-tk package<br>aradnix@Melania-V5-131:~/Documentos/Python 3$ <br>
</div><div><br></div><div>Entonces pensé en buscar los módulos instalados en mi sistema, que es 14.04 LTS, busqué como ver eso, encontré aquí: <a href="http://agregando.es/2009/11/python-como-saber-que-modulos-tengo-instalados/">http://agregando.es/2009/11/python-como-saber-que-modulos-tengo-instalados/</a> y al ejecutar en terminal pydoc modules como recomienda obtuve lo siguiente:<br>
<br>aradnix@Melania-V5-131:~$ pydoc modules<br><br>Please wait a moment while I gather a list of all available modules...<br><br>/usr/lib/python2.7/dist-packages/relatorio/templates/__init__.py:43: UserWarning: Unable to load plugin 'chart', you will not be able to use it<br>
<br>Original traceback:<br>-------------------<br>Traceback (most recent call last):<br> File "/usr/lib/python2.7/dist-packages/relatorio/templates/__init__.py", line 32, in <module><br> __import__('relatorio.templates.%s' % name)<br>
File "/usr/lib/python2.7/dist-packages/relatorio/templates/chart.py", line 28, in <module><br> import yaml<br>ImportError: No module named yaml<br><br><br> warnings.warn(tb_file.getvalue())<br>/usr/lib/python2.7/pkgutil.py:110: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible.<br>
__import__(name)<br>ANSI argparse ihooks scanext<br>BaseHTTPServer array imaplib sched<br>Bastion ast imghdr scipy<br>
BeautifulSoup asynchat imp scour<br>BeautifulSoupTests asyncore importlib screen<br>CDROM atexit imputil screenlets<br>CGIHTTPServer atk indicator_keyboard select<br>
Canvas audiodev inspect serial<br>CommandNotFound audioop invest sessioninstaller<br>ConfigParser autoreload io sets<br>Cookie axi itertools sgmllib<br>
Crypto base64 jinja2 sha<br>DLFCN bdb joblib shelve<br>Dialog binascii json shlex<br>DocXMLRPCServer binhex keyword shutil<br>
FSM bisect ldap signal<br>FileDialog blueman ldapurl simplegeneric<br>FixTk bonobo ldb simplejson<br>
GMenuSimpleEditor bookletimposer ldif sip<br>HTMLParser bs4 lib2to3 sipconfig<br>IN bsddb libturpial sipconfig_nd<br>IPython bz2 libxml2 site<br>
Image cPickle libxml2mod sitecustomize<br>ImageChops cProfile linecache six<br>ImageColor cStringIO linuxaudiodev smbc<br>ImageCrackCode cairo locale smtpd<br>
ImageDraw calendar lockfile smtplib<br>ImageEnhance ccm logging sndhdr<br>ImageFile cgi lsb_release socket<br>ImageFileIO cgitb lxml softwarecenter_aptd_plugins<br>
ImageFilter chardet macpath sortsmill<br>ImageFont chunk macurl2path spwd<br>ImageGL cmath mailbox sql<br>ImageGrab cmd mailcap sqlite3<br>
ImageMath code markupbase sre<br>ImageOps codecs markupsafe sre_compile<br>ImagePalette codeop marshal sre_constants<br>ImagePath collections math sre_parse<br>
ImageQt colorsys matplotlib ssl<br>ImageSequence commands md5 stat<br>ImageStat compileall mhlib statsmodels<br>ImageTk compiler mimetools statvfs<br>
ImageWin compizconfig mimetypes storemagic<br>Levenshtein contextlib mimify string<br>MimeWriter cookielib mmap stringold<br>MySQLdb copy modulefinder stringprep<br>
ORBit copy_reg mpl_toolkits strop<br>OpenSSL crypt multifile struct<br>PAM csv multiprocessing subprocess<br>PIL ctypes mutex suds<br>
PSDraw cups mx sunau<br>PngImagePlugin cupsext neso sunaudio<br>PyQt4 cupshelpers netrc svg_regex<br>Queue curl new svg_transform<br>
ScrolledText curses nis symbol<br>SimpleDialog cvxopt nntplib sympy<br>SimpleHTTPServer cythonmagic nose sympyprinting<br>SimpleXMLRPCServer datetime ntdb symtable<br>
SocketServer dateutil ntpath sys<br>StringIO dbhash nturl2path sysconfig<br>TYPES dbm numbers syslog<br>Tix dbus numexpr tables<br>
Tkconstants deb822 numpy tabnanny<br>Tkdnd debconf oauth talloc<br>Tkinter debian oauthlib tarfile<br>UbuntuSystemService debian_bundle octavemagic tdb<br>
UserDict debtagshw oneconf telnetlib<br>UserList decimal opcode tempfile<br>UserString decorator openpyxl termios<br>_LWPCookieJar defer operator test<br>
_MozillaCookieJar difflib optparse textwrap<br>__builtin__ dircache os this<br>__future__ dirspec os2emxpath thread<br>_abcoll dis ossaudiodev threading<br>
_ast distutils pandas tidy<br>_bisect doctest pango time<br>_blueman dot_parser pangocairo timeit<br>_bsddb drv_libxml2 parallelmagic tkColorChooser<br>
_codecs dsextras parser tkCommonDialog<br>_codecs_cn dsml patsy tkFileDialog<br>_codecs_hk dumbdbm pcardext tkFont<br>
_codecs_iso2022 dummy_thread pdb tkMessageBox<br>_codecs_jp dummy_threading pdfimposer tkSimpleDialog<br>_codecs_kr duplicity pexpect toaiff<br>
_codecs_tw email pickle token<br>_collections encodings pickletools tokenize<br>_csv errno pipes tornado<br>_ctypes exceptions piston_mini_client trace<br>
_ctypes_test fcntl pkg_resources traceback<br>_curses fdpexpect pkgutil tryton<br>_curses_panel feedparser platform trytond<br>_dbus_bindings filecmp plistlib ttk<br>
_dbus_glib_bindings fileinput polib tty<br>_elementtree fnmatch popen2 turpial<br>_functools fontforge poplib turtle<br>_hashlib formatter posix twisted<br>
_heapq fpectl posixfile types<br>_hotshot fpformat posixpath ubuntu_sso<br>_io fractions pprint unicodedata<br>_json ftplib profile uniconvertor<br>
_ldap functools psMat unittest<br>_locale future_builtins pstats urllib<br>_lsprof gc psycopg2 urllib2<br>_md5 gconf pty urllib3<br>
_multibytecodec gdbm pwd urlparse<br>_multiprocessing genericpath pxssh user<br>_mysql genshi pyPdf uu<br>_mysql_exceptions getopt py_compile uuid<br>
_osx_support getpass pyclbr vatnumber<br>_pyio gettext pycurl vobject<br>_random gi pydoc warnings<br>_sha gio pydoc_data wave<br>
_sha256 glib pydot weakref<br>_sha512 glob pyexpat webbrowser<br>_smbc gmenu pygst webkit<br>_socket gnome pygtk whichdb<br>
_sqlite3 gnomecanvas pygtkcompat winpdb<br>_sre gnomekeyring pylab wnck<br>_ssl gnomevfs pynotify wsgiref<br>_strptime gobject pyparsing wx<br>
_struct gpgme pytz wxPython<br>_symtable grp pywebdav wxversion<br>_sysconfigdata gst quopri xapian<br>_sysconfigdata_nd gstoption random xdg<br>
_testcapi gtk re xdiagnose<br>_threading_local gtkunixprint readline xdrlib<br>_tkinter gtweak relatorio xlrd<br>_warnings gzip reportlab xlwt<br>
_weakref hashlib repr xml<br>_weakrefset heapq requests xmllib<br>abc hmac resource xmlrpclib<br>aifc hotshot rexec xxsubtype<br>
antigravity hpmudext rfc822 yocto_css<br>antlr html5lib rlcompleter zeitgeist<br>anydbm htmlentitydefs rmagic zipfile<br>apt htmllib robotparser zipimport<br>
apt_inst httplib rpdb2 zlib<br>apt_pkg httplib2 rsvg zmq<br>aptdaemon ibus runpy zope<br>aptsources idlelib samba <br>
<br>Enter any module name to get more help. Or, type "modules spam" to search<br>for modules whose descriptions contain the word "spam".<br><br></div><div>Donde aparece el modulo que usé: turtle, por lo que el error no parece ser la falta del módulo, pero parece ser que faltan otros ya que hay unas advertencias (warnings) que supongo no deben ignorarse pero no sé a que aludan o como se resuelvan ¿alguien sabe cómo?<br>
<br></div><div>Saludos<br></div></div></div></div>