modoboa / modoboa-imap-migration

An extension to ease the migration between 2 IMAP servers using offlineimap
ISC License
16 stars 12 forks source link

setup of database tables failed ("ImportError: No module named modoboa_amavis") #52

Closed mamair closed 3 years ago

mamair commented 5 years ago

Just got following error message. "modoboa_amavis" is in settings.py, so I dont know why I get this message. Installing offlineimap caused also some problems, because python3 is installed and I had to downgrade python-imaplib2 I use debian stretch

python manage.py migrate modoboa_imap_migration Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/Django-1.11.20-py2.7.egg/django/core/management/init.py", line 364, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/Django-1.11.20-py2.7.egg/django/core/management/init.py", line 308, in execute settings.INSTALLED_APPS File "/usr/local/lib/python2.7/dist-packages/Django-1.11.20-py2.7.egg/django/conf/init.py", line 56, in getattr self._setup(name) File "/usr/local/lib/python2.7/dist-packages/Django-1.11.20-py2.7.egg/django/conf/init.py", line 41, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/dist-packages/Django-1.11.20-py2.7.egg/django/conf/init.py", line 110, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/srv/modoboa/instance/instance/settings.py", line 333, in from modoboa_amavis import settings as modoboa_amavis_settings ImportError: No module named modoboa_amavis

Running the installation script previously there were a lot of warnings about missing files, just at the beginning too ...:

python setup.py install running install running bdist_egg running egg_info creating modoboa_imap_migration.egg-info writing requirements to modoboa_imap_migration.egg-info/requires.txt writing modoboa_imap_migration.egg-info/PKG-INFO writing top-level names to modoboa_imap_migration.egg-info/top_level.txt writing dependency_links to modoboa_imap_migration.egg-info/dependency_links.txt writing manifest file 'modoboa_imap_migration.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'COPYING' warning: no files found matching '.js' under directory 'modoboa_imap_migration' warning: no files found matching '.css' under directory 'modoboa_imap_migration' ..... In between masses of missing files warnings and so on ... .....

warning: no previously-included files matching '*.py[co]' found anywhere in distribution no previously-included directories found matching 'docs/_build' File "build/bdist.linux-x86_64/egg/jinja2/asyncsupport.py", line 22 async def concat_async(async_gen): ^ SyntaxError: invalid syntax

File "build/bdist.linux-x86_64/egg/jinja2/asyncfilters.py", line 7 async def auto_to_seq(value): ^ SyntaxError: invalid syntax

creating /usr/local/lib/python2.7/dist-packages/Jinja2-2.10.1-py2.7.egg Extracting Jinja2-2.10.1-py2.7.egg to /usr/local/lib/python2.7/dist-packages File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.10.1-py2.7.egg/jinja2/asyncsupport.py", line 22 async def concat_async(async_gen): ^ SyntaxError: invalid syntax

File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.10.1-py2.7.egg/jinja2/asyncfilters.py", line 7 async def auto_to_seq(value): ^ SyntaxError: invalid syntax

mamair commented 5 years ago

The second part with the masses of file not found warnings was because of false order of steps following your instruction. Just put "'modoboa_imap_migration.auth_backends.IMAPBackend'," BEFORE restart of uwsgi service and starting of install script for databases ...

mamair commented 5 years ago

Processes running listening to ports: tcp 0 0 0.0.0.0:9123 0.0.0.0: LISTEN 967/java
tcp 0 0 localhost.localdo:10024 0.0.0.0:
LISTEN 1702/amavisd-new (m tcp 0 0 0.0.0.0:8233 0.0.0.0: LISTEN 17447/nginx: master tcp 0 0 localhost.localdo:10025 0.0.0.0: LISTEN 30692/master
tcp 0 0 localhost.localdo:10026 0.0.0.0: LISTEN 1702/amavisd-new (m tcp 0 0 0.0.0.0:submission 0.0.0.0: LISTEN 30692/master
tcp 0 0 localhost.localdo:11211 0.0.0.0: LISTEN 910/memcached
tcp 0 0 localhost.localdom:9998 0.0.0.0:
LISTEN 1702/amavisd-new (m tcp 0 0 0.0.0.0:imap2 0.0.0.0:* LISTEN 1016/dovecot
tcp 0 0 .** http 0.0.0.0: LISTEN 10829/hiawatha
tcp 0 0 localhost.localdom:5232 0.0.0.0: LISTEN 1959/python3
tcp 0 0 0.0.0.0:8277 0.0.0.0:
LISTEN 17447/nginx: master tcp 0 0
.**.at:domain 0.0.0.0: LISTEN 13513/pdns_server
tcp 0 0 0.0.0.0:ssh 0.0.0.0: LISTEN 976/sshd
tcp 0 0 localhost.lo:postgresql 0.0.0.0:
LISTEN 31595/postgres
tcp 0 0 0.0.0.0:smtp 0.0.0.0: LISTEN 30692/master
tcp 0 0 localhost.localdo:12345 0.0.0.0:
LISTEN 1042/opendkim
tcp 0 0 0.0.0.0:4443 0.0.0.0: LISTEN 967/java
tcp 0 0 0.0.0.0:sieve 0.0.0.0:
LISTEN 1016/dovecot
tcp 0 0 0.0.0.0:4000 0.0.0.0: LISTEN 967/java
tcp 0 0 0.0.0.0:imaps 0.0.0.0:
LISTEN 1016/dovecot
tcp6 0 0 ip6-localhost:10024 [::]: LISTEN 1702/amavisd-new (m tcp6 0 0 [::]:8233 [::]: LISTEN 17447/nginx: master tcp6 0 0 [::]:mysql [::]: LISTEN 13316/mysqld
tcp6 0 0 ip6-localhost:10026 [::]:
LISTEN 1702/amavisd-new (m tcp6 0 0 ip6-localhost:9998 [::]: LISTEN 1702/amavisd-new (m tcp6 0 0 [::]:imap2 [::]: LISTEN 1016/dovecot
tcp6 0 0 [::]:8277 [::]: LISTEN 17447/nginx: master tcp6 0 0 [::]:domain [::]: LISTEN 13513/pdns_server
tcp6 0 0 [::]:ssh [::]: LISTEN 976/sshd
tcp6 0 0 [::]:sieve [::]:
LISTEN 1016/dovecot
tcp6 0 0 [::]:imaps [::]:* LISTEN 1016/dovecot

mamair commented 5 years ago

Processes running listening to ports: tcp 0 0 0.0.0.0:9123 0.0.0.0: LISTEN 967/java
tcp 0 0 localhost.localdo:10024 0.0.0.0:
LISTEN 1702/amavisd-new (m tcp 0 0 0.0.0.0:8233 0.0.0.0: LISTEN 17447/nginx: master tcp 0 0 localhost.localdo:10025 0.0.0.0: LISTEN 30692/master
tcp 0 0 localhost.localdo:10026 0.0.0.0: LISTEN 1702/amavisd-new (m tcp 0 0 0.0.0.0:submission 0.0.0.0: LISTEN 30692/master
tcp 0 0 localhost.localdo:11211 0.0.0.0: LISTEN 910/memcached
tcp 0 0 localhost.localdom:9998 0.0.0.0:
LISTEN 1702/amavisd-new (m tcp 0 0 0.0.0.0:imap2 0.0.0.0:* LISTEN 1016/dovecot
tcp 0 0 .** http 0.0.0.0: LISTEN 10829/hiawatha
tcp 0 0 localhost.localdom:5232 0.0.0.0: LISTEN 1959/python3
tcp 0 0 0.0.0.0:8277 0.0.0.0:
LISTEN 17447/nginx: master tcp 0 0
.**.at:domain 0.0.0.0: LISTEN 13513/pdns_server
tcp 0 0 0.0.0.0:ssh 0.0.0.0: LISTEN 976/sshd
tcp 0 0 localhost.lo:postgresql 0.0.0.0:
LISTEN 31595/postgres
tcp 0 0 0.0.0.0:smtp 0.0.0.0: LISTEN 30692/master
tcp 0 0 localhost.localdo:12345 0.0.0.0:
LISTEN 1042/opendkim
tcp 0 0 0.0.0.0:4443 0.0.0.0: LISTEN 967/java
tcp 0 0 0.0.0.0:sieve 0.0.0.0:
LISTEN 1016/dovecot
tcp 0 0 0.0.0.0:4000 0.0.0.0: LISTEN 967/java
tcp 0 0 0.0.0.0:imaps 0.0.0.0:
LISTEN 1016/dovecot
tcp6 0 0 ip6-localhost:10024 [::]: LISTEN 1702/amavisd-new (m tcp6 0 0 [::]:8233 [::]: LISTEN 17447/nginx: master tcp6 0 0 [::]:mysql [::]: LISTEN 13316/mysqld
tcp6 0 0 ip6-localhost:10026 [::]:
LISTEN 1702/amavisd-new (m tcp6 0 0 ip6-localhost:9998 [::]: LISTEN 1702/amavisd-new (m tcp6 0 0 [::]:imap2 [::]: LISTEN 1016/dovecot
tcp6 0 0 [::]:8277 [::]: LISTEN 17447/nginx: master tcp6 0 0 [::]:domain [::]: LISTEN 13513/pdns_server
tcp6 0 0 [::]:ssh [::]: LISTEN 976/sshd
tcp6 0 0 [::]:sieve [::]:
LISTEN 1016/dovecot
tcp6 0 0 [::]:imaps [::]:* LISTEN 1016/dovecot

mamair commented 5 years ago

Following packages had to be downgraded to install OfflinrIMAP: libssl-dev libssl1.1 openssl

What is the correct way to install OfflineIMAP? I used debian pachacke. As I see Python2 is part of modoboas python or whatever environment. So I just have to install OfflineIMAP as a part of this environment? How ...

tonioo commented 5 years ago

@mamair Using the latest version is a good idea. Check the official documentation here: http://www.offlineimap.org/doc/installation.html.

jamietb commented 5 years ago

I'm also experiencing this problem and haven't been able to fix it yet.

I made a clean install of Ubuntu 18.04 then installed Modoboa as follows:-

sudo apt-get install python-virtualenv python-pip
git clone https://github.com/modoboa/modoboa-installer
cd modoboa-installer
sudo ./run.py <your domain>

All went fine and the server came to life. Then I tried adding the IMAP migration extension:-

pip install modoboa-imap-migration
cd <modoboa_instance_dir>
python manage.py migrate

At this point I then get the following error:-

Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 364, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 308, in execute settings.INSTALLED_APPS File "/usr/local/lib/python2.7/dist-packages/django/conf/init.py", line 56, in getattr self._setup(name) File "/usr/local/lib/python2.7/dist-packages/django/conf/init.py", line 41, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/dist-packages/django/conf/init.py", line 110, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/srv/modoboa/instance/instance/settings.py", line 336, in from modoboa_amavis import settings as modoboa_amavis_settings ImportError: No module named modoboa_amavis

Does anybody have any ideas on how to fix this please?

Thanks, Jamie.

jamietb commented 5 years ago

I've now fixed my issue by following the install guide after activating the virtual env.

source /srv/modoboa/env/bin/activate

However I couldn't do this under user modoboa and had to use root. I thought the auto installer would have set this up to be used as modoboa?

tonioo commented 5 years ago

You should be able to load the virtualenv as modoboa. Why do you say it doesn't work?

jamietb commented 5 years ago

@tonioo it always says

source: not found

it works fine if I add the user modoboa to the sudo group though

str1n commented 4 years ago

I had the same problem twice with fresh installs on Ubuntu 18.04.3 LTS, running on an AWS t3a.small instance (2 cores, 2Gb RAM). Issue 990 (for an older version of Modoboa) suggests it is because the extension is not installed. Similar to axd in that issue, these should all have been installed by the installer - yet if I manually install them via pip then I get a step further through the install - until it failed with a MySQL issue, at which point I gave up, wiped the volumes and will start again for the third time (probably tomorrow now, using postgres instead).

I was trying to install the modoboa-imap-migration extension to migrate 6 mailboxes from another Postfix server via IMAP.

I followed the installation instructions, and when I get to this bit

> sudo -u <modoboa_user> -i
> source <virtuenv_path>/bin/activate 

Same as @jamietb I also get source: not found

UPDATE: This is because source is a bash command, whereas the -i switch on sudo ignores the user's default shell. I tried the -s switch instead of -i, but ran into permission issues. So instead, I started a bash shell in between:

> sudo -u <modoboa_user> -i
> bash
> source <virtuenv_path>/bin/activate 

Then, when I try to run:

$ cd <modoboa_instance_dir>
$ python manage.py migrate

I got missing module errors (for everything that should have been installed by the installed. So, still in the bash shell as user modoboa, I installed them manually:

$ pip install modoboa_amavis
$ python manage.py migrate
$ pip install modoboa_contacts
$ python manage.py migrate
$ pip install modoboa_radicale
$ python manage.py migrate
$ pip install modoboa_pdfcredentials
$ python manage.py migrate
$ pip install modoboa_postfix_autoreply
$ python manage.py migrate
$ pip install modoboa_sievefilters
$ python manage.py migrate
$ pip install modoboa_stats
$ python manage.py migrate
$ pip install modoboa_webmail
$ python manage.py migrate
$ pip install psycopg2
$ python manage.py migrate

I then edited instance/settings.py to add the imap-migration specifics, then:

$ python manage.py migrate modoboa_imap_migration
$ python manage.py load_initial_data

Basically, each time I ran python manage.py migrate I got an error message saying there was a missing module, so I then installed it and tried again. In the end, the modoboa_imap_migration extension appears to have installed correctly with the initial data loaded.

At this point everything seems to be working - next I will attempt to migrate the 6 users over IMAP...will update later.

UPDATE Unfortunately after restarting I am now getting a server error - so unfortunately looks like Modoboa is not the choice for me having tried 3 times on clean installs. I think if you are looking for a brand new server with nothing to migrate, then it could be okay, but these issues concern me so will revert to a manual install of postfix, amavis, roundcube, postgrey, etc.