Search code examples
peeweepipenv

Unable to load ManyToManyField from playhouse.fields through pipenv


I am having the problem of being unable to import the ManyToManyField from playhouse.fields on an Ubuntu server where I am using pipenv to manage packages and run python. Namely the command

from playhouse.fields import ManyToManyField

will lead to the error:

ImportError: cannot import name ManyToManyField

When I am using the same import command on my computer, it works, so this problem might be related to the virtual environment of pipenv. However, maybe this is a problem of different versions and you could help me. Additionally, the import command from playhouse. Shortcuts import ManyToManyField works. Could I use this instead of the playhouse. Fields entry? Are they the same? Can you tell me, why it might not find the ManyToManyField in the playhouse.fields? I would be grateful for any reference. Thank you in advance!


Solution

  • I don't use pipenv but it sounds like on your computer you've got an old (2.x) version cached and on the server you're running the newer version (3.x).

    In peewee 3.x, you import ManyToManyField from peewee:

    from peewee import ManyToManyField