Import Error: No module named wordwrap

239 views
Skip to first unread message

llanitedave

unread,
May 19, 2012, 11:26:57 PM5/19/12
to wxpytho...@googlegroups.com

I'm currently working on two wxPython applications – one I'm developing myself, and the other is Open Stereo, described by Carlos Grohmann on this list last week. Once again, I'm baffled (a rather common state for me, unfortunately)


I have tested both applications on Ubuntu, Kubuntu, and LXCE in the 11.10 versions, and they both worked. In addition, Open Stereo works on Python 2.7 in my Windows 7 partition.


Recently I upgraded to Ubuntu 12.04, including the KDE version. At that point, Open Stereo ceased working. Opening from the command line, I got the following error message:


...from wx.lib.wordwrap import wordwrap

ImportError: No module named wordwrap


The relevant modules imported in the offending source file are:


import wx

import os, sys, csv

from wx.lib.pubsub import Publisher as pub

import types as types

from wx.lib.wordwrap import wordwrap

import matplotlib as mpl


Wondering if somehow wxPython had been corrupted, I transferred the line

from wx.lib.wordwrap import wordwrap

to my own application. It started up with no errors!


Both applications are in adjacent directories in my /home/Documents?WorkRelated folder, so I don't see any path issues. I have the zipped version of both Open Stereo and the current wxPython in my Downloads folder; I reinstalled both of them, but nothing changed.


Sorry for the long-winded text, but I'm stymied. How can a module from the same toolkit be nonexistent for one application yet available for another one right next door?


It still works on Windows, btw, but I really don't want to shift my work over unless I absolutely have to. Any hints would be appreciated.  Right now I feel like the blindfolded kid searching for the pinata.

Mike Driscoll

unread,
May 21, 2012, 11:25:13 AM5/21/12
to wxpytho...@googlegroups.com
You could try importing sys and then writing out sys.path to a file to see if there's a difference in path lookup. I don't know why there would be, but that might help in debugging it.

- Mike

llanitedave

unread,
May 22, 2012, 5:28:14 PM5/22/12
to wxpytho...@googlegroups.com
Thanks, Mike, you hit that one on the nose!  The applications call different paths -- Open Stereo's path ends with  

'/usr/lib/python2.7/dist-packages/wx-2.6-gtk2-unicode', while mine starts with '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'.  I didn't even know I had 2.6 installed.


Now I need to figure out how to change it!

Mike Driscoll

unread,
May 22, 2012, 5:40:42 PM5/22/12
to wxpytho...@googlegroups.com


On Tuesday, May 22, 2012 4:28:14 PM UTC-5, llanitedave wrote:
Thanks, Mike, you hit that one on the nose!  The applications call different paths -- Open Stereo's path ends with  

'/usr/lib/python2.7/dist-packages/wx-2.6-gtk2-unicode', while mine starts with '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'.  I didn't even know I had 2.6 installed.


Now I need to figure out how to change it!




Ugh. wxPython 2.6 is super old. I would try to uninstall it and then maybe Open Stereo will pick up the right one. If not, you may need to reinstall the newer 2.8 again. You can also wxversion: http://wiki.wxpython.org/MultiVersionInstalls#How_do_I_use_wxversion.3F

llanitedave

unread,
May 22, 2012, 6:22:57 PM5/22/12
to wxpytho...@googlegroups.com
Got it!  From your link, I simply added

import wxversion
wxversion.select("2.8")

Above the import wx command, and everything is working correctly now!

I'm still wondering why it took the Ubuntu 12.04 upgrade to throw it all out of kilter, but I'll definitely be getting rid of wx-2.6.

Thank you very much, Mike.

BTW, I have already gotten some valuable tips from your blog, too.

Dave
Reply all
Reply to author
Forward
0 new messages