I tried the same statements (on Mac) and I cannot reproduce the problem.
Anyway, note the logic:
NATIVE_IMPORTER = __builtin__.__import__
...
def custom_importer(name, globals=None, locals=None, fromlist=None,
level=-1):
....
return NATIVE_IMPORTER(name, globals, locals, fromlist, level) # line 87
So basically the custom_importer is doing nothing but delegating the
native_importer (__builtin__.__import__) with the same arguments.
If you have any idea please let me know. If you can give me access to the
server I can try some debugging.
massimo
On Tuesday, 6 November 2012 01:58:38 UTC-6, Neil wrote:
>
> It seems to be there, as I can import it from a normal python shell. Here
> is what I get from the web2py shell:
>
> >>> from matplotlib.projections.geo import AitoffAxes
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> File
> "/home/aicbt/webapps/alternate_config/web2py2.2.1/gluon/custom_import.py",
> line 87, in custom_importer
> return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
> File
> "/home/aicbt/lib/python2.7/matplotlib-1.1.0-py2.7-linux-x86_64.egg/matplotlib/projections/__init__.py",
>
> line 1, in <module>
> from geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
> ImportError: cannot import name AitoffAxes
>
> Email me if you would like me to arrange access to the server for a faster
> debug cycle (unfortunately I'm a little too busy to investigate this myself
> at the moment).
>
> On Tuesday, November 6, 2012 4:43:39 AM UTC, Massimo Di Pierro wrote:
>>
>> can you do
>>
>> from matplotlib.projections.geo import AitoffAxes
>>
>> I assume it is there.
>>
>> On Monday, 5 November 2012 16:10:14 UTC-6, Neil wrote:
>>>
>>> No problem. Here is what I get:
>>>
>>> >>> import matplotlib.pylab
>>> Traceback (most recent call last):
>>> File "<console>", line 1, in <module>
>>> File
>>> "/home/aicbt/webapps/alternate_config/web2py2.2.1/gluon/custom_import.py",
>>> line 87, in custom_importer
>>> return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
>>> File
>>> "/home/aicbt/lib/python2.7/matplotlib-1.1.0-py2.7-linux-x86_64.egg/matplotlib/pylab.py",
>>>
>>> line 221, in <module>
>>> from matplotlib import mpl # pulls in most modules
>>> File
>>> "/home/aicbt/webapps/alternate_config/web2py2.2.1/gluon/custom_import.py",
>>> line 87, in custom_importer
>>> return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
>>> File
>>> "/home/aicbt/lib/python2.7/matplotlib-1.1.0-py2.7-linux-x86_64.egg/matplotlib/mpl.py",
>>>
>>> line 10, in <module>
>>> from matplotlib import figure
>>> File
>>> "/home/aicbt/webapps/alternate_config/web2py2.2.1/gluon/custom_import.py",
>>> line 87, in custom_importer
>>> return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
>>> File
>>> "/home/aicbt/lib/python2.7/matplotlib-1.1.0-py2.7-linux-x86_64.egg/matplotlib/figure.py",
>>>
>>> line 29, in <module>
>>> from projections import projection_factory, get_projection_names, \
>>> File
>>> "/home/aicbt/webapps/alternate_config/web2py2.2.1/gluon/custom_import.py",
>>> line 87, in custom_importer
>>> return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
>>> File
>>> "/home/aicbt/lib/python2.7/matplotlib-1.1.0-py2.7-linux-x86_64.egg/matplotlib/projections/__init__.py",
>>>
>>> line 1, in <module>
>>> from geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
>>> ImportError: cannot import name AitoffAxes
>>>
>>> On Friday, November 2, 2012 3:48:53 PM UTC, Massimo Di Pierro wrote:
>>>>
>>>> I need your help. In gluon/custom_import.py can you replace
>>>>
>>>> except ImportError, e1: # line 84
>>>> import_tb = sys.exc_info()[2]
>>>> try:
>>>> return NATIVE_IMPORTER(name, globals, locals, fromlist,
>>>> level) # line 87
>>>> except ImportError, e3:
>>>> raise ImportError, e1, import_tb # there an import
>>>> error in the module
>>>>
>>>> with
>>>>
>>>> except ImportError, e1: # line 84
>>>> import_tb = sys.exc_info()[2]
>>>> return NATIVE_IMPORTER(name, globals, locals, fromlist,
>>>> level) # line 87
>>>>
>>>> and see what changes?
>>>>
>>>>
>>>>
>>>> On Friday, 2 November 2012 09:09:03 UTC-5, Neil wrote:
>>>>>
>>>>> Can't see any potential conflicts. I have the problem for both
>>>>> track_changes(True) and track_changes(False). When I import from shell:
>>>>>
>>>>> [aicbt@web331 web2py2.2.1]$ python web2py.py -S init
>>>>> web2py Web Framework
>>>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>>>> Version 2.2.1 (2012-10-21 16:57:04) stable
>>>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
>>>>> MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000), IMAP(imaplib)
>>>>> WARNING:web2py:import IPython error; use default python shell
>>>>> Python 2.7.3 (default, May 18 2012, 14:51:16)
>>>>> [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
>>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> (InteractiveConsole)
>>>>> >>> import matplotlib.pylab
>>>>> Traceback (most recent call last):
>>>>> File "<console>", line 1, in <module>
>>>>> File
>>>>> "/home/aicbt/webapps/alternate_config/web2py2.2.1/gluon/custom_import.py",
>>>>>
>>>>> line 77, in custom_importer
>>>>> raise ImportError, 'Cannot import module %s' % str(e)
>>>>> ImportError: Cannot import module 'matplotlib'
>>>>>
>>>>> This shell command works with web2py version 2.1. Also, "import
>>>>> matplotlib" (without the pylab) works fine for 2.2.1.
>>>>>
>>>>> On Friday, November 2, 2012 1:22:03 PM UTC, Massimo Di Pierro wrote:
>>>>>>
>>>>>> Do you have anything in your app/modules/* that may conflict? Did
>>>>>> you set track_changes(True) or not? If you do web2py.py -S yourapp can
>>>>>> you
>>>>>> import form the web2py shell?
>>>>>>
>>>>>> On Friday, 2 November 2012 02:18:47 UTC-5, Neil wrote:
>>>>>>>
>>>>>>> A little more info:
>>>>>>>
>>>>>>> - On linux (works fine on Windows)
>>>>>>> - matplotlib is an egg in the lib directory
>>>>>>> - "import matplotlib" works, but "import matplotlib.pylab" doesn't
>>>>>>> - Has worked fine in every version up to 2.1
>>>>>>>
>>>>>>> Any ideas for a workaround or to debug further?
>>>>>>>
>>>>>>> On Thursday, November 1, 2012 9:52:57 PM UTC, Massimo Di Pierro
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Where is matplotlib installed?
>>>>>>>>
>>>>>>>> On Thursday, 1 November 2012 15:51:14 UTC-5, Neil wrote:
>>>>>>>>>
>>>>>>>>> I just upgraded from 2.1 to 2.2.1, and I can no longer import
>>>>>>>>> matplotlib. I get the following error:
>>>>>>>>>
>>>>>>>>> ImportError: Cannot import module 'matplotlib'
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Is this related to the custom import? Perhaps it is the same as issue
>>>>>>>>> 1125?
>>>>>>>>>
>>>>>>>>>
--