Closed kaizeng closed 6 years ago
@kaizeng - what python version are you using?
Please provide the output of pyq --versions
command.
@abalkin Thanks very much for your very prompt reply. Here is the information:
$ pyq --version
Python 2.7.12 :: Anaconda custom (64-bit)
@kaizeng - sorry, I asked for pyq --versions
with an s
at the end. This is a pyq specific option that print more information than just --version
. Also, what are the versions of scipy
and statsmodels
?
@abalkin - sorry i misread it. Here is the pyq version:
$ pyq --versions
PyQ 4.1.1
NumPy 1.11.2
KDB+ 3.3 (2016.02.02) l64
Python 2.7.12 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
and
>>> scipy.__version__
'0.18.1'
and
>>> statsmodels.__version__
'0.8.0'
@kaizeng - I was able to reproduce your issue. We will fix it in the next release. Meanwhile, please try the following workaround:
import pyq
del pyq.lazy_converters['collections']
from statsmodels.compat.collections import OrderedDict
Check that the conversion works:
>>> pyq.K(OrderedDict([('a',1)]))
k('(,`a)!,1')
@abalkin Thank you very much! I really appreciate your help! The workaround is working perfectly in the meantime!
I was able to reproduce this issue without statsmodels by simply creating a "compat" directory
compat/
__init__.py
collections.py
with an empty __init__.py
and the following line in collections.py
:
from collections import OrderedDict
With this setup,
$ pyq
Python 2.7.13 (default, Jun 13 2017, 14:40:28)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from compat.collections import OrderedDict
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/a/.virtualenvs/d/lib/python2.7/site-packages/pyq/__init__.py", line 774, in __import__
m = _imp(name, globals, locals, fromlist, level)
File "compat/collections.py", line 2, in <module>
from collections import OrderedDict
File "/Users/a/.virtualenvs/d/lib/python2.7/site-packages/pyq/__init__.py", line 777, in __import__
_c.update((getattr(m, cname), conv) for cname, conv in pairs)
File "/Users/a/.virtualenvs/d/lib/python2.7/site-packages/pyq/__init__.py", line 777, in <genexpr>
_c.update((getattr(m, cname), conv) for cname, conv in pairs)
AttributeError: 'module' object has no attribute 'OrderedDict'
I feel this is a bug in statsmodels rather than pyq because adding
from __future__ import absolute_import
at the top of the compat/collections.py
file fixes the problem.
The issue has been fixed in the third party code. See statsmodels/statsmodels#3976.
@abalkin Thanks a lot for the updates! I really appreciate your help!
threw an exception:
I think we used to have this bug in
3.8.x
version but it has been fixed. Not sure why it comes back again.Thanks a lot!