On 08/28/2012 12:35 PM, Steven D'Aprano wrote: > On 29/08/12 03:41, Ray Jones wrote: >> I'm working on another Python replacement for a Bash script, and I ran >> into a need for enhanced time zone functions. Following directions I >> found on a web site, I did the following: >> >> # easy_install --upgrade pytz > [...] >> Everything I'm reading suggests that now I should have the pytz module >> available to me. But from iPython: > >> ImportError: No module named pytz > > > Any time you get mysterious errors in iPython, or IDLE, or any other > add-on to Python, it is important to determine whether the problem is > with Python itself, or the add-on. > > In this case, start up the vanilla Python interactive environment by > entering "python" at the $ prompt, then "import pytz" at the >>> prompt. > > If you get an error: > > - copy and paste the full traceback > > - show us the contents of sys.path > > > You can also determine how many Python installations you have. At the > bash $ prompt, type: > > python TAB TAB > > (that is, press the TAB key twice is succession, do not type the > letters "t" "a" "b") > > and your shell will list the possible executable Python's on your > system. Copy and paste that output. > I tried importing the module with each of the three shells that I have on my system (I think I need to get rid of idle - I never use it anymore): python, ipython, and idle. None of them recognize the module.
Discovering which python binaries are available shows that I have /usr/bin/python and /usr/bin/python2.7. /usr/bin/python is a link to /usr/bin/python2.7. My sys.path shows the following: ['', '', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/pymodules/python2.7/gtk-2.0', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/dist-packages/IPython/Extensions', u'/home/ray/.ipython'] Aha! The sys path is in /usr/lib but the module was installed in /usr/local/lib. What's the easiest fix for this? Creating a link to the module in the OS, or adding (or changing) the sys.path? Ray _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor