jakeret / hope

HOPE: A Python Just-In-Time compiler for astrophysical computations
GNU General Public License v3.0
382 stars 28 forks source link

error when trying to compile function -- ImportError: No module named 'winreg' from six library #27

Closed astronomeralex closed 9 years ago

astronomeralex commented 9 years ago

I'm using python 3.3, hope 0.3.1, on Mac 10.9.5 with clang 3.4. When I try the basic sum example, I get this error from the six library. I have the most recent version of six (1.8.0) installed and I'm uncertain if this is an issue with hope or truly an issues with six.

In [1]: from hope import jit

In [2]: @jit
   ...: def jitsum(x,y):
   ...:     return x + y
   ...: 

In [3]: jitsum(1,2)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-64161ff6ad22> in <module>()
----> 1 jitsum(1,2)

/astro/grads/arh5361/code/anaconda/lib/python3.3/site-packages/hope/_wrapper.py in _hope_callback(*args)
     69 
     70         def _hope_callback(*args):
---> 71             return self(*args) if self.cache is None else self.cache(*args)
     72         self.callback = _hope_callback
     73         setattr(cache, str(id(self.callback)), fkt)

/astro/grads/arh5361/code/anaconda/lib/python3.3/site-packages/hope/_wrapper.py in __call__(self, *args)
    121 
    122             for name in list(sys.modules.keys()):
--> 123                 if hasattr(sys.modules[name], self.fkt.__name__) and getattr(sys.modules[name], self.fkt.__name__) is self.callback:
    124                     setattr(sys.modules[name], self.fkt.__name__, module.run)
    125             setattr(cache, str(id(module.run)), self.fkt)

/astro/grads/arh5361/code/anaconda/lib/python3.3/site-packages/astropy/extern/bundled/six.py in __getattr__(self, attr)
    114         if attr in ("__file__", "__name__") and self.mod not in sys.modules:
    115             raise AttributeError
--> 116         _module = self._resolve()
    117         value = getattr(_module, attr)
    118         setattr(self, attr, value)

/astro/grads/arh5361/code/anaconda/lib/python3.3/site-packages/astropy/extern/bundled/six.py in _resolve(self)
    103 
    104     def _resolve(self):
--> 105         return _import_module(self.mod)
    106 
    107     def __getattr__(self, attr):

/astro/grads/arh5361/code/anaconda/lib/python3.3/site-packages/astropy/extern/bundled/six.py in _import_module(name)
     74 def _import_module(name):
     75     """Import module, returning the module after the last dot."""
---> 76     __import__(name)
     77     return sys.modules[name]
     78 

ImportError: No module named 'winreg'
cosmo-ethz commented 9 years ago

@astronomeralex winreg is not a package HOPE relies on. So the whole thing looks a bit weird. Could you try to run HOPE in a virtualenv. For instance you could clone the repository and then execute the unit tests with make test-all or with tox -e py33.

astronomeralex commented 9 years ago

@cosmo-ethz this bug disappeared after i deleted the .hope directory for Issue #26. This could be some strange error that pops up when switching back and forth between python27 and 33.

cosmo-ethz commented 9 years ago

Ok good. Glad it helped.