offlineimap not calling right version of python that i picked with anaconda

92 views
Skip to first unread message

Jim McNamara

unread,
Jul 5, 2022, 1:54:29 PM7/5/22
to mu-discuss
Hi Dirk and everyone-

I installed a version earlier than python 3.10 with anaconda.
I activated it and can run the correct version with python --version.
However, when I run this command:

$/usr/bin/offlineimap -c ~/.offlineimap/offlineimap.conf

it is picking a different version of python :

OfflineIMAP 8.0.0
 Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.05, Python v3.10.4, OpenSSL 3.0.2 15 Mar 2022

I am trying to test an earlier version  3.9.4 of python to see if it works better, but offlineimap doesn't seem to get it that I am in that environment even after I activate it.

[general]
# List of accounts to be synced, separated by a comma.
accounts = main

[Account main]
# Identifier for the local repository; e.g. the maildir to be synced via IMAP.
localrepository = main-local
# Identifier for the remote repository; i.e. the actual IMAP, usually non-local.
remoterepository = main-remote

[Repository main-local]
# OfflineIMAP supports Maildir, GmailMaildir, and IMAP for local repositories.
type = Maildir
# Where should the mail be placed?
localfolders = ~/MailDir


[Repository main-remote]
# OfflineIMAP supports Maildir, GmailMaildir, and IMAP for local repositories.
# Where should the mail be placed?
localfolders = ~/MailDir
# SSL and STARTTLS are enabled by default.
type = IMAP
tls_level = tls_compat
ssl=yes
remotehost = mobile.charter.net
remoteuser = myemail
# Necessary for SSL connections, if using offlineimap version > 6.5.4
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
# Synchronize only the folders Inbox and Sent:
folderfilter = lambda foldername: foldername in ["Inbox", "Sent Mail", "Drafts", "Spam", "Trash"]

the above code is generating an error that reads:

Account sync main:
*** Processing account main
Establishing connection to mobile.charter.net:993 (main-remote)
ERROR: While attempting to sync account 'main'
 'int' object is not subscriptable
*** Finished account 'main' in 0:00
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'main'
 'int' object is not subscriptable

Traceback:
 File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
   self.__sync()
 File "/usr/share/offlineimap3/offlineimap/accounts.py", line 374, in __sync
   remoterepos.getfolders()
 File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders
   imapobj = self.imapserver.acquireconnection()
 File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 683, in acquireconnection
   e.args[0][:35] == 'IMAP4 protocol error: socket error:':

THANKS for any assistance!
robo-loki

Joost Kremers

unread,
Jul 5, 2022, 2:26:52 PM7/5/22
to mu-di...@googlegroups.com, Jim McNamara

On Tue, Jul 05 2022, Jim McNamara wrote:
> I am trying to test an earlier version 3.9.4 of python to see if it works
> better, but offlineimap doesn't seem to get it that I am in that
> environment even after I activate it.

Ah, the beauty of Python. One would think that after the debacle that was the
2.7 to 3.x transition the devs would know better. But apparently they haven't
had enough and are aiming for even greater confusion by not even changing the
major version...

It seems that every time I try to use Python 3.10, something turns out to be
incompatible and I need to revert to 3.9. Luckily I'm using a distro that's
conservative enough to keep 3.9 the system Python.

Anyway, to turn to your problem: I don't think you can use an Anaconda
environment to run a system Python script, at least not without some additional
work. A virtualenv is basically just a separate shell process with a properly
manipulated PATH variable. In order for offlineimap to use the virtualenv, you'd
have to make sure it's started inside the env. A globally installed offlineimap
normally won't.

The simplest solution would really be to downgrade your system Python to 3.9,
but I don't how easy that is in your case. It will depend on the distro you're
using.

Alternatively, you may try using [pyenv](https://github.com/pyenv/pyenv) (note:
not "pyvenv"!) to install Python 3.9 next to 3.10 and make it the default
version for your system. I'm not sure if that will work, though, I've never had
the occasion to try.

Another approach would be to look at the way offlineimap is run. You could, of
course, start it manually from a bash shell after activating the virtualenv you
created for it (and keep it running in daemon mode). It should also be possible
to create a wrapper script for offlineimap that first activates the virtualenv
and then runs offlineimap inside it.

Very general advice, I know... Perhaps it can put you in the right direction.

Joost



--
Joost Kremers
Life has its moments

Jim McNamara

unread,
Jul 5, 2022, 2:35:26 PM7/5/22
to mu-discuss
Hi Joost-

Very cool. I will see where I can go with your advice.

THANKS

Eduardo Mercovich

unread,
Jul 5, 2022, 2:38:44 PM7/5/22
to mu-di...@googlegroups.com, Jim McNamara
Hi Jim.

> I installed a version earlier than python 3.10 [...] However, when I run this command:
>
> $/usr/bin/offlineimap -c ~/.offlineimap/offlineimap.conf
> it is picking a different version of python :

In Joost fashion this is not what you asked, but... ;P I had a much better experience with mbsync.

Just in case, you know, in this case seems better to have too much info that too few. ;D

Best...

--
Eduardo Mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.
(Anónimo)

Jim McNamara

unread,
Jul 7, 2022, 6:48:06 PM7/7/22
to mu-discuss
Hi Eduardo-

I used mbsync and i making a little progress gettng it hooked up.
It works better for me than offlineimap3.

thanks for the advice
roboloki

Ray Kinsella

unread,
Aug 10, 2022, 1:07:35 AM8/10/22
to mu-di...@googlegroups.com, Jim McNamara

Jim McNamara <nefario...@gmail.com> writes:

> Hi Dirk and everyone-
>
> I installed a version earlier than python 3.10 with anaconda.
> I activated it and can run the correct version with python --version.
> However, when I run this command:
>
> $/usr/bin/offlineimap -c ~/.offlineimap/offlineimap.conf
>
> it is picking a different version of python :
>
> OfflineIMAP 8.0.0
> Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
> imaplib2 v3.05, Python v3.10.4, OpenSSL 3.0.2 15 Mar 2022

I am guessing at what is happening here - but I'd say it is likely that
'python3' symlink is still pointing at 3.10.4. You may need to use
'update-alternatives' to set the correct version of python you want to
use for 'python3'.
--
Regards, Ray K
Reply all
Reply to author
Forward
0 new messages