XaviTorello / mail2googlegroup

Import email to Google Groups. Migration tool (imap and mbox)
GNU Affero General Public License v3.0
31 stars 7 forks source link

mbox2gg: cannot import name 'Q' from 'imap_tools' #3

Closed markusicu closed 2 months ago

markusicu commented 3 years ago

I tried mbox2gg and it quickly failed with this:

Traceback (most recent call last):
  File "/home/username/.local/bin/mbox2gg", line 5, in <module>
    from mail2gg.cli import execute_mbox_importer
  File "/home/username/.local/lib/python3.8/site-packages/mail2gg/__init__.py", line 12, in <module>
    from imap_tools import MailBox, Q
ImportError: cannot import name 'Q' from 'imap_tools' (/home/username/.local/lib/python3.8/site-packages/imap_tools/__init__.py)
JeffHochberg commented 3 years ago

I'm running into exactly the same issue - I've tried with Python 3.8 on Ubuntu Linux 20.04 and Python 3.9 on macOS Big Sur.

On Ubuntu:

username@ubuntu:~$ mbox2gg --help
Traceback (most recent call last):
  File "/home/username/.local/bin/mbox2gg", line 5, in <module>
    from mail2gg.cli import execute_mbox_importer
  File "/home/username/.local/lib/python3.8/site-packages/mail2gg/__init__.py", line 12, in <module>
    from imap_tools import MailBox, Q
ImportError: cannot import name 'Q' from 'imap_tools' (/home/username/.local/lib/python3.8/site-packages/imap_tools/__init__.py)

On macOS:

username@MacBook-Air ATGP % imap2gg --help            
Traceback (most recent call last):
  File "/usr/local/bin/imap2gg", line 5, in <module>
    from mail2gg.cli import execute_imap_importer
  File "/usr/local/lib/python3.9/site-packages/mail2gg/__init__.py", line 12, in <module>
    from imap_tools import MailBox, Q
ImportError: cannot import name 'Q' from 'imap_tools' (/usr/local/lib/python3.9/site-packages/imap_tools/__init__.py)
XaviTorello commented 3 years ago

Sorry for the delay, I was out @markusicu and @JeffHochberg.

As a quick workaround, imap_tools should be downgraded to <=0.30.0

In 0.31.0, Q was removed (https://github.com/ikvk/imap_tools/releases/tag/v0.31.0)

I'm going to enforce it in the requirements as a workaround until the code uses the new imap_tools APIs.

XaviTorello commented 3 years ago

New version has been uploaded to pypi, so just pip install mail2gg --upgrade to reach it

Could you please confirm that works as expected? @markusicu @JeffHochberg

JeffHochberg commented 3 years ago

Hi @XaviTorello - yes I was able to upgrade mail2gg and execute mbox2gg which is what I was looking for!

I'm running into Google Groups API errors now, so I need to troubleshoot that, but I wanted to let you know that the changes you made fixed the original problem. Thanks!

JeffHochberg commented 3 years ago

I posted a follow-up question to see if there was any additional logging that could be enabled as I was seeing a stream of 401 errors coming back from the Google Groups Migration API. It turns out that the API cannot be used to import content into an @googlegroups.com group. They only support Google Workspace (a.k.a. G Suite for Business). I tried creating a Google Workspace Group and that worked as expected!

XaviTorello commented 3 years ago

Great @JeffHochberg, ty for confirming it 👌

JeffHochberg commented 3 years ago

@XaviTorello it's up to you obviously, but I think you can close this bug as resolved...unless you're waiting for @markusicu