Tortoise-orm: ImportError: cannot import name 'basestring' from 'pypika.terms'

Created on 29 Apr 2020  路  6Comments  路  Source: tortoise/tortoise-orm

Describe the bug
excpetion occue when from tortoise.filters import get_m2m_filters
python3.8 x64
Ubuntu 16.04 18.04

To Reproduce

  1. pip3 install 'tortoise-orm >=0.16.6'
  2. from tortoise.filters import get_m2m_filters

Expected behavior
No error

Additional context

In [1]: from tortoise.filters import get_m2m_filters
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-4ed7453a3d83> in <module>
----> 1 from tortoise.filters import get_m2m_filters

/usr/local/lib/python3.8/dist-packages/tortoise/__init__.py in <module>
     23     OneToOneFieldInstance,
     24 )
---> 25 from tortoise.filters import get_m2m_filters
     26 from tortoise.models import Model
     27 from tortoise.queryset import QuerySet

/usr/local/lib/python3.8/dist-packages/tortoise/filters.py in <module>
      5 from pypika import Table
      6 from pypika.functions import Upper
----> 7 from pypika.terms import (
      8     BasicCriterion,
      9     Criterion,

ImportError: cannot import name 'basestring' from 'pypika.terms' (/usr/local/lib/python3.8/dist-packages/pypika/terms.py)
Waiting for feedback regression

Most helpful comment

Hi I released 0.16.10 with the fix :smile:

All 6 comments

but tortoise-orm==0.16.5 has not this problem
or pip3 install -U pypika==0.37.1

pypika remove basestring in https://github.com/kayak/pypika/pull/413/files/b44d70c2bdcedcc7526c39ee782664db9b9c4264

Thanks for reporting! I'll make hotfix for this issue and will be fixed with next release

Oh my. This was me. basestring isn't really a thing anymore, a regular str should be perfectly fine.

This should be fixed in our develop branch.

Please test by installing pip install https://github.com/tortoise/tortoise-orm/archive/develop.zip

Thanks @lntuition ! (it was actually him)

That helped me. Thanks

This should be fixed in our develop branch.

Please test by installing pip install https://github.com/tortoise/tortoise-orm/archive/develop.zip

Thanks @lntuition ! (it was actually him)

Hi I released 0.16.10 with the fix :smile:

Was this page helpful?
0 / 5 - 0 ratings