1

Topic: ImportError: cannot import name settings

==== Required information ====
- iRedMail version: 0.8.6
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PostgreSQL
- Linux/BSD distribution name and version: Ubuntu 14.04 LTS
- Related log if you're reporting an issue:
====

Please note: I am a fairly seasoned Python developer, and I know my way around Apache and mod_wsgi fairly well.

Same issue as the following posts, settings.py not found, even though permissions are correct:

* http://www.iredmail.org/forum/topic6622 … rface.html
* http://www.iredmail.org/forum/topic6602 … rrors.html
* http://www.iredmail.org/forum/topic6565 … ation.html

[Tue Apr 22 19:55:08.400732 2014] [:error] [pid 9541] [client x.x.x.x] mod_wsgi (pid=9541): Target WSGI script '/usr/share/apache2/iredadmin/iredadmin.py' cannot be loaded as Python module.
[Tue Apr 22 19:55:08.400778 2014] [:error] [pid 9541] [client x.x.x.x] mod_wsgi (pid=9541): Exception occurred processing WSGI script '/usr/share/apache2/iredadmin/iredadmin.py'.
[Tue Apr 22 19:55:08.400802 2014] [:error] [pid 9541] [client x.x.x.x] Traceback (most recent call last):
[Tue Apr 22 19:55:08.400823 2014] [:error] [pid 9541] [client x.x.x.x]   File "/usr/share/apache2/iredadmin/iredadmin.py", line 9, in <module>
[Tue Apr 22 19:55:08.400898 2014] [:error] [pid 9541] [client x.x.x.x]     from libs import iredbase
[Tue Apr 22 19:55:08.400914 2014] [:error] [pid 9541] [client x.x.x.x]   File "/usr/share/apache2/iredadmin/libs/iredbase.py", line 18, in <module>
[Tue Apr 22 19:55:08.401015 2014] [:error] [pid 9541] [client x.x.x.x]     import iredutils
[Tue Apr 22 19:55:08.401030 2014] [:error] [pid 9541] [client x.x.x.x]   File "/usr/share/apache2/iredadmin/libs/iredutils.py", line 13, in <module>
[Tue Apr 22 19:55:08.401225 2014] [:error] [pid 9541] [client x.x.x.x]     import settings
[Tue Apr 22 19:55:08.401252 2014] [:error] [pid 9541] [client x.x.x.x] ImportError: cannot import name settings

-r--------  1 iredadmin iredadmin  3914 Apr 22 10:29 settings.py

I wondered if the file permissions meant that Apache can't read the file, changed it to 444, but that didn't help. I also went and added WSGIPythonPath /usr/share/apache2/iredadmin/ to the default-ssl.conf file, but that didn't help either.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: ImportError: cannot import name settings

Hrm, OK, I caught the tail end of one of those posts, ran "sudo a2enconf iredadmin" and got a little further:

[Tue Apr 22 20:27:46.133238 2014] [:error] [pid 10387] [remote x.x.x.x] Traceback (most recent call last):
[Tue Apr 22 20:27:46.133289 2014] [:error] [pid 10387] [remote x.x.x.x]   File "/usr/lib/python2.7/dist-packages/web/application.py", line 237, in process
[Tue Apr 22 20:27:46.133295 2014] [:error] [pid 10387] [remote x.x.x.x]     return p(lambda: process(processors))
[Tue Apr 22 20:27:46.133301 2014] [:error] [pid 10387] [remote x.x.x.x]   File "/usr/lib/python2.7/dist-packages/web/session.py", line 84, in _processor
[Tue Apr 22 20:27:46.133320 2014] [:error] [pid 10387] [remote x.x.x.x]     self._cleanup()
[Tue Apr 22 20:27:46.133326 2014] [:error] [pid 10387] [remote x.x.x.x]   File "/usr/lib/python2.7/dist-packages/web/session.py", line 172, in _cleanup
[Tue Apr 22 20:27:46.133331 2014] [:error] [pid 10387] [remote x.x.x.x]     self.store.cleanup(timeout)
[Tue Apr 22 20:27:46.133336 2014] [:error] [pid 10387] [remote x.x.x.x]   File "/usr/lib/python2.7/dist-packages/web/session.py", line 319, in cleanup
[Tue Apr 22 20:27:46.133341 2014] [:error] [pid 10387] [remote x.x.x.x]     self.db.delete(self.table, where="$last_allowed_time > atime", vars=locals())
[Tue Apr 22 20:27:46.133346 2014] [:error] [pid 10387] [remote x.x.x.x]   File "/usr/lib/python2.7/dist-packages/web/db.py", line 907, in delete
[Tue Apr 22 20:27:46.133350 2014] [:error] [pid 10387] [remote x.x.x.x]     self._db_execute(db_cursor, q)
[Tue Apr 22 20:27:46.133355 2014] [:error] [pid 10387] [remote x.x.x.x]   File "/usr/lib/python2.7/dist-packages/web/db.py", line 587, in _db_execute
[Tue Apr 22 20:27:46.133360 2014] [:error] [pid 10387] [remote x.x.x.x]     out = cur.execute(query, params)
[Tue Apr 22 20:27:46.133365 2014] [:error] [pid 10387] [remote x.x.x.x] ProgrammingError: relation "sessions" does not exist
[Tue Apr 22 20:27:46.133370 2014] [:error] [pid 10387] [remote x.x.x.x] LINE 1: DELETE FROM sessions WHERE '2014-04-21T20:27:46.117384'::tim...
[Tue Apr 22 20:27:46.133375 2014] [:error] [pid 10387] [remote x.x.x.x]                     ^
[Tue Apr 22 20:27:46.133379 2014] [:error] [pid 10387] [remote x.x.x.x]

3

Re: ImportError: cannot import name settings

raoul wrote:

[Tue Apr 22 20:27:46.133365 2014] [:error] [pid 10387] [remote x.x.x.x] ProgrammingError: relation "sessions" does not exist

Do you have database "iredadmin" in PostgreSQL database server? Looks like your iRedMail installation was unsuccessfully completed.

4

Re: ImportError: cannot import name settings

I thought it had completed successfully, but looking at the output now, it didn't.

********************************************************************
* Start iRedMail Configurations
********************************************************************
< INFO > Create self-signed SSL certification files.
< INFO > Create required system accounts: vmail, iredapd, iredadmin.
< INFO > Configure Apache web server and PHP.
< INFO > Configure PostgreSQL database server.
Can't open /etc/postgresql/9.1/main/postgresql.conf: No such file or directory.
Can't open /etc/postgresql/9.1/main/postgresql.conf: No such file or directory.
ln: failed to create symbolic link '/var/lib/postgresql/9.1/main/server.crt': No such file or directory
ln: failed to create symbolic link '/var/lib/postgresql/9.1/main/server.key': No such file or directory
cp: cannot create regular file '/var/lib/postgresql/9.1/main/vmail.sql': No such file or directory
cp: cannot create regular file '/var/lib/postgresql/9.1/main/init.sql': No such file or directory
chmod: cannot access '/var/lib/postgresql/9.1/main/vmail.sql': No such file or directory
chmod: cannot access '/var/lib/postgresql/9.1/main/init.sql': No such file or directory
/var/lib/postgresql/9.1/main/init.sql: No such file or directory
< INFO > Configure Postfix (Message Transfer Agent).
< INFO > Configure Cluebringer (postfix policy server).
< INFO > Configure Dovecot-2 (pop3/imap/managesieve server).
< INFO > Configure ClamAV (anti-virus toolkit).
< INFO > Configure Amavisd-new (interface between MTA and content checkers).
< INFO > Configure SpamAssassin (content-based spam filter).
< INFO > Configure iRedAPD (postfix policy daemon).
< INFO > Configure iRedAdmin (official web-based admin panel).
cp: cannot create regular file '/var/lib/postgresql/9.1/main/': No such file or directory
chmod: cannot access '/var/lib/postgresql/9.1/main/iredadmin.pgsql': No such file or directory
/var/lib/postgresql/9.1/main/iredadmin.pgsql: No such file or directory
ERROR:  relation "sessions" does not exist
ERROR:  relation "log_id_seq" does not exist
< INFO > Configure Fail2ban (authentication failure monitor).
< INFO > Configure Awstats (logfile analyzer for mail and web server).
< INFO > Configure Roundcube webmail.
\connect: FATAL:  database "vmail" does not exist
< INFO > Configure phpPgAdmin (web-based PostgreSQL management tool).

*************************************************************************
* iRedMail-0.8.6 installation and configuration complete.
*************************************************************************

5

Re: ImportError: cannot import name settings

Ah, it's because 14.04 comes with PostgreSQL 9.3, not 9.1.

6

Re: ImportError: cannot import name settings

I reinstalled the server, modified the iRedMail install script to set the PostgreSQL version to 9.3, and ran "sudo a2enconf iredadmin" and now everything is up and running.

As someone else commented, the default apache files are now located in /var/www/html instead of /var/www, so I also had to change that to get the redirect to work.

7

Re: ImportError: cannot import name settings

raoul wrote:

Ah, it's because 14.04 comes with PostgreSQL 9.3, not 9.1.

...the default apache files are now located in /var/www/html instead of /var/www ...

Both were fixed and will be available in upcoming iRedMail release, thanks for your feedback. smile