Cannot import module 'applications.welcome.modules.pytz

42 views
Skip to first unread message

icodk

unread,
Nov 30, 2017, 2:18:35 PM11/30/17
to web2py-users
What I did:

added
import pytz

in db.py in the welcome application 

The error:

<type 'exceptions.ImportError'> (ImportError("Cannot import module 'applications.welcome.modules.pytz'",), <traceback object at 0x7fc194275bd8>)


Environment:

2.16.1-stable+timestamp.2017.11.14.05.54.25
(Running on nginx/1.12.1, Python 2.7.14)

fresh web2py installation on Ubuntu 17.10 using the script: setup-web2py-nginx-uwsgi-ubuntu.sh

python version in terminal:

Python 2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


Any idea ?

icodk

unread,
Nov 30, 2017, 5:42:41 PM11/30/17
to web2py-users
SOLVED !
use:
sudo pip install pytz

and not
pip install pytz


if you install pytz using pip without sudo , it will be installed for the login user and will be inaccessible from uwsgi/nginx
Example:
yourname@yourserver:~$pip install pytz

will install it in

 /home/yourname/.local/lib/python2.7/site-packages/pytz/

you can check it by starting python, importing pytz and then typing pytz. This will show the complete path of the library.

>>>import pytz
>>> pytz
<module 'pytz' from '/home/yourname/.local/lib/python2.7/site-packages/pytz/__init__.pyc'>
>>>
while installing it with
sudo pip install pytz

will install it in :
<module 'pytz' from '/usr/local/lib/python2.7/dist-packages/pytz/__init__.pyc'>

Neil

unread,
Dec 1, 2017, 2:07:11 PM12/1/17
to web2py-users
Reply all
Reply to author
Forward
0 new messages