Closed PeterDSteinberg closed 6 years ago
Replicated the CI issue locally with:
conda create -n dask-searchcv-test -c conda-forge dask-searchcv python=2.7
source activate dask-searchcv-test
cd dask_searchcv/tests/
conda install pytest
py.test
Strange... I'm not able to reproduce this locally.
Will take a closer look later.
I just ran into this myself in a different library. The error occurs when the non-LooseVersion
is a unicode object in python 2:
>>> from distutils.version import LooseVersion
>>> LooseVersion('0.21.0') < u'0.21.0'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jcrist/anaconda/envs/py27/lib/python2.7/distutils/version.py", line 296, in __cmp__
return cmp(self.version, other.version)
AttributeError: 'unicode' object has no attribute 'version'
However, I'm baffled how this is happening in the code, since the strings compared are just the default string type (not unicode at all). I'm unable to reproduce locally for either this issue or others. Googling turns up a few other occurrences of this, but none of them offer suggestions as to why this happens.
Possibly someone imports unicode_literals
?
In [1]: from distutils.version import LooseVersion
In [2]: LooseVersion('0.21.0') < '0.21.0'
Out[2]: False
In [3]: from __future__ import unicode_literals
In [4]: LooseVersion('0.21.0') < '0.21.0'
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-8b388f046a2e> in <module>()
----> 1 LooseVersion('0.21.0') < '0.21.0'
/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/version.pyc in __cmp__(self, other)
294 other = LooseVersion(other)
295
--> 296 return cmp(self.version, other.version)
297
298
AttributeError: 'unicode' object has no attribute 'version'
I'll search around, but IIRC the current recommendation is that libraries not import unicode literals.
http://python-future.org/unicode_literals.html waffles. I suppose that means libraries should not use unicode_literals, since they can't assume downstream applications are expecting it to be turned on.
@PeterDSteinberg I noticed elm does import unicode_literals. Does that stem from a specific issue, or convenience?
Closing as this isn't an issue with dask-searchcv directly.
I encountered this bug in a dask-searchcv
LooseVersion
Python 2.7 usage withelm
in CI. It appears to be the same idea as thisLooseVersion
issue python.org issue 14894.To avoid attribute error, fix this line for Python 2.7:
if LooseVersion(dask.__version__) > '0.15.4'