ratt-ru/meqtrees-timba

can't import TDL scripts doe to six.py / _winreg

Closed this issue · 4 comments

Traceback (most recent call last):
  File "/home/oms/Timba/install/symlinked-release/libexec/python/Timba/TDL/Compile.py", line 141, in import_tdl_module
    _update_modlist();
  File "/home/oms/Timba/install/symlinked-release/libexec/python/Timba/TDL/Compile.py", line 65, in _update_modlist
    if not getattr(sys.modules[name],'_tdl_no_reimport',False)]);
  File "/usr/lib/python2.7/dist-packages/six.py", line 116, in __getattr__
    _module = self._resolve()
  File "/usr/lib/python2.7/dist-packages/six.py", line 105, in _resolve
    return _import_module(self.mod)
  File "/usr/lib/python2.7/dist-packages/six.py", line 76, in _import_module
    __import__(name)
ImportError: No module named _winreg

WTF knows what's going on here. Meqtrees is just scanning the Python module list and checking for a magic attribute -- six.py doesn't like its attributes checked anymore and pukes. Commens in six.py mention Django. @gijzelaerr, any idea?

     def __getattr__(self, attr):
        # Hack around the Django autoreloader. The reloader tries to get
        # __file__ or __name__ of every module in sys.modules. This doesn't work
        # well if this MovedModule is for an module that is unavailable on this
        # machine (like winreg on Unix systems). Thus, we pretend __file__ and
        # __name__ don't exist if the module hasn't been loaded yet. See issues
        # #51 and #53.
        if attr in ("__file__", "__name__") and self.mod not in sys.modules:
            raise AttributeError
        _module = self._resolve()
        value = getattr(_module, attr)
        setattr(self, attr, value)
        return value

so I don't think you have ever thought about writinh python3 compatible code, that is where the six module is for. isn't six installed by accident and maybe there is a module name collision or something?

aplpy could possibly be the culprit -- I had similar issue recently,
updated aplpy and it was sorted.

On 9 October 2015 at 16:14, Gijs Molenaar notifications@github.com wrote:

so I don't think you have ever thought about writinh python3 compatible
code, that is where the six module is for. isn't six installed by accident
and maybe there is a module name collision or something?


Reply to this email directly or view it on GitHub
#24 (comment)
.

Egads! Well, no excuse to have meqtrees fall over just because some other package is the wrong version. This is some deep Python hoodoo. Rather than stir the evil beast, easier to hack around it: c3a4085

Winreg my ass! Microsoft crap will get you everywhere. Especially when you're not looking.