error: 'No module named sanitizer' after upgrading to 2.16.1

127 views
Skip to first unread message

Ton Sjerps

unread,
Nov 20, 2017, 4:46:07 PM11/20/17
to web2py-users
After upgrading from 2.15.4 it gave the ticket below.
Unfortunately putting it back to the previous or an even older version did not solve the problem.
Searching the web it seems to be related to python libs html5lib and bleach
reinstalling or updating them with 'pip install -U bleach' does not seem to help and neither does installing a previous version of the html5lib with 'pip install html5lib==1.0b9'

The problem exists while testing locally on my laptop as well as on the server.
The server I could only get back up and running by restoring it to the backup off last night.
(restored to version 2.14.6-stable+timestamp.2016.05.10.00.21.47  Apache/2.4.18 (Ubuntu), Python 2.7.12)

Anybody any suggestions on what the problem is and how to tackle it?

web2py™ Version 2.16.1-stable+timestamp.2017.11.14.05.54.25
Python Python 2.7.14: D:\Python27\python.exe (prefix: D:\Python27)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.



Traceback (most recent call last):
File "F:\5-PCPROG\web2py_src\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "F:/5-PCPROG/web2py_src/web2py/applications/apa/controllers/orders.py", line 3, in <module>
from sanitizer import sanitize
File "F:\5-PCPROG\web2py_src\web2py\gluon\custom_import.py", line 104, in custom_importer
raise ImportError(e1, import_tb) # there an import error in the module
ImportError: (ImportError('No module named sanitizer',), <traceback object at 0x0000000004E69748>)

Massimo Di Pierro

unread,
Nov 21, 2017, 9:20:46 PM11/21/17
to web2py-users
check that you have
web2py/gluon/sanitizer.py
maybe you accidentally deleted it or maybe the user does not have read permission.
Another option is that you app does a non thread safe os.chdir()

Ton Sjerps

unread,
Dec 27, 2017, 7:36:40 AM12/27/17
to web2py-users
Thanks for your suggestions.
The only working solution seemed to be to revert to version 2.14.6.
The simplest solution though was to delete the line 'from sanitizer import sanitize' altogether
(don't remember how/why it got there to start with).
Why this line has such an unexpected effect on post 2.14.6 versions puzzels me but I haven't seen it anymore (yett).
It's now working again, also with 2.14.6

fyi: With the eclipse debugger you see crash in function
 custom_importer at the if-statement because 'request' is no element of 'current') 
   try:
        if current.request._custom_import_track_changes:
            base_importer = TRACK_IMPORTER
        else:
            base_importer = NATIVE_IMPORTER
    except:  # there is no current.request (should never happen)
        base_importer = NATIVE_IMPORTER


Op maandag 20 november 2017 22:46:07 UTC+1 schreef Ton Sjerps:

Leonel Câmara

unread,
Jan 23, 2018, 12:06:44 PM1/23/18
to web2py-users
The problem here was that your controller is using:

from sanitizer import sanitize

When now you should use

from gluon.sanitizer import sanitize

Ton Sjerps

unread,
Jan 23, 2018, 2:23:30 PM1/23/18
to web2py-users
Removing the statement altogether also works.
I think the statement got there automatically by eclipse (or by means of an unintend use of a shortcut for doing that).
I've seen more examples of this since using eclipse, be warned.
Thanks for your help

Op dinsdag 23 januari 2018 18:06:44 UTC+1 schreef Leonel Câmara:
Reply all
Reply to author
Forward
0 new messages