Issue #217 new

UserWarning: Module paste was already imported from None

Jan Dittberner
created an issue

on a system using distribute 0.6.16 and virtualenvwrapper I get warnings like

{{{ /usr/lib/pymodules/python2.6/virtualenvwrapper/hook_loader.py:16: UserWarning: Module paste was already imported from None, but /usr/lib/python2.6/dist-packages is being added to sys.path import pkg_resources }}}

I first thought that this might be an issue with virtualenvwrapper, but this is unlikely because the same virtualenvwrapper version does not give the problem with an older distribute version (0.6.14). Please see the discussion at https://bitbucket.org/dhellmann/virtualenvwrapper/issue/99/hook_loaderpy-warning too.

Comments (4)

  1. Yaroslav Halchenko

    I got annoyed by this bug as well... unfortunately I do not know standards and namespaces handling that well to claim anything, but in case of 'paste' it seems due to the fact that

    1. whenever 'site' module is loaded it processes .pth files (unless started with -S)

    2. paste framework, to enable its namespaces provides /usr/lib/python2.6/dist-packages/Paste-1.7.5.1-nspkg.pth which, I guess from itse code:

    import sys,types,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('paste',)); ie = os.path.exists(os.path.join(p,'__init__.py')); m = not ie and sys.modules.setdefault('paste',types.ModuleType('paste')); mp = (m or []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and mp.append(p)
    

    forces preloading of 'paste' module so it appears as part of sys.modules whenever you start plain Python, e.g.:

    $> python -c 'import sys; print sys.modules["paste"]'
    <module 'paste' (built-in)>
    

    and there is no file associated since there is no init.py per se, so distribute's check

    fn = getattr(sys.modules[modname], '__file__', None)
    

    results in None

    thus the loop in check_version_conflict doesn't "continue" but issues a warning.

    So I wonder if that is paste people at fault who somehow had to register 'paste' namespace or distribute which might allow additional "continue" in the the loop such as (may be additionally conditioned on fn being None)

                pn = getattr(sys.modules[modname], '__path__', None)
                if pn and pn == [ os.path.join(loc, modname) ]:
                    continue
    

    Thank you in advance for looking into this. Cheers!

  2. Anonymous
  3. Log in to comment