Re: [web2py] Re: app not loading external python library
pip install urllib3_secure_extra in my virtual env solved the problem. Thank you Tom for pointing to the solution, I had missed that thread. On October 27, 2023 at 16:59:18, Tom Clerckx (tcler...@gmail.com) wrote: I think this is the same issue as was discussed a few months ago: See this thread: https://groups.google.com/g/web2py/c/xYVWpDGLuzY/m/t9sBabWOAgAJ Seems some issue between the custom importer and the urllib3 module. Can you try once more, but also explicitly pip install *urllib3_secure_extra *in your virtual env? On Thursday, October 26, 2023 at 7:33:25 AM UTC+2 Massimo Di Pierro wrote: > Hello Alex, > > thank for reporting this problem. Is it only occurring with web2py 2.25.1? > > On Monday, 23 October 2023 at 14:05:15 UTC-7 alex wrote: > >> Hi, >> >> I am running web2py Version 2.25.1-stable in virtualenv (python 3.9.5, it >> happens also in python 3.10.10) >> >> After activating the virtualenv, I installed requests >> >> $ pip install request >> $ pip show requests >> Name: requests >> Version: 2.31.0 >> Summary: Python HTTP for Humans. >> Home-page: https://requests.readthedocs.io >> Author: Kenneth Reitz >> Author-email: m...@kennethreitz.org >> License: Apache 2.0 >> Location: >> /Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages >> Requires: certifi, charset-normalizer, idna, urllib3 >> Required-by: >> >> Importing requests from bpython gives no errors. >> >> Importing requests in myapp gives an error. >> I also tried with other external libraries, some of them do work, some >> others cannot be imported. >> >> About this case, I have tried the following: >> >> In "web2py/applications/myapp/models/0.py": >> >> # - - - - - - - - - - - - - - - >> >> # added the virtualenv path to sys.path >> >> site_package_path = >> "/Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages" >> >> if site_package_path not in sys.path: >> sys.path.append(site_package_path) >> >> try: >> import requests >> except: >> raise Exception('import error: "requests" not found') >> >> >> # - - - - - - - - - - - - - - - >> >> I am running web2py with: >> >> $python web2py.py -a 'pwd' >> >> Error log: >> >> # - - - - - - - - - - - - - - - >> Ticket ID >> 127.0.0.1.2023-10-24.05-48-51.a557dcfb-55a3-4063-ac27-879cad8fe799 >> >> import error: "requests" not found >> Version >> web2py™ Version 2.25.1-stable+timestamp.2023.10.08.18.44.43 >> Python Python 3.9.5: /Users/z/dev/web2py/.direnv/python-3.9/bin/python >> (prefix: /Users/z/dev/web2py/.direnv/python-3.9) >> >> ... >> >> Traceback (most recent call last): >> File "/Users/z/dev/web2py/gluon/custom_import.py", line 78, in >> custom_importer >> result = sys.modules[modules_prefix] >> KeyError: 'applications.wh.modules.requests' >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "/Users/z/dev/web2py/applications/wh/models/0.py", line 29, in >> >> import requests >> File "/Users/z/dev/web2py/gluon/custom_import.py", line 80, in >> custom_importer >> raise ImportError("No module named %s" % modules_prefix) >> ImportError: No module named applications.wh.modules.requests >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "/Users/z/dev/web2py/gluon/restricted.py", line 219, in restricted >> exec(ccode, environment) >> File "/Users/z/dev/web2py/applications/wh/models/0.py", line 31, in >> >> raise Exception('import error: "requests" not found') >> Exception: import error: "requests" not found >> Error snapshot help >> Exception(import error: "requests" not found) >> >> inspect attributes >> >> Exception instance attributes >> __cause__ None >> __class__ >> __context__ ImportError('No module named >> applications.wh.modules.requests') >> __delattr__ >> __dict__ {} >> __dir__ >> __doc__ 'Common base class for all non-exit exceptions.' >> __eq__ >> __format__ >> __ge__ >> __getattribute__ >> __gt__ >> __hash__ >> __init__ >> __init_subclass__ >> __le__ >> __lt__ >> __ne__ >> __new__ >> __reduce__ >> __reduce_ex__ >> __repr__ >> __setattr__ >> __setstate__ >> __sizeof__ >> __str__ >> __subclasshook__ >> __suppress_context__ False >> __traceback__ >> args ('import error: "requests" not found',) >> with_traceback >> Frames >> File /Users/z/dev/web2py/gluon/restricted.py in restricted at line 219 >> code arguments variables >> >> File /Users/z/dev/web2py/applications/wh/models/0.py in at line >> 31 code arguments variables >> >> Function argument list >> () >> >> Context locals >> >> ... >> >> >> >> iteritems : >> > >> local_import : >> .> >> myconf : >> {'app': {'name': 'WH', 'author': 'Your Name > 'bootstrap3_inline', 'separator': ''}} >> redirect : >> >> reduce : >> >> request : >> , >> '_custom_import_track_changes': True}> >> response : >> > 'view': 'default/index.html'}> >> session : >> >> site_package_path : >>
[web2py] web2py 2.25.1 - bug when running interactive shell?
I believe web2py/gluon/shell.py", line 238 should use os.path.*abspath* instead of *absdir*? Unpacked and ran a clean version of web2py: command: python web2py.py -B -S welcome -M web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2023 Version 2.25.1-stable+timestamp.2023.10.08.18.44.43 Database drivers available: sqlite3, imaplib, pymysql, pyodbc Traceback (most recent call last): File "/odindrive/temp/web2pytest/web2py/web2py.py", line 58, in gluon.widget.start() File "/odindrive/temp/web2pytest/web2py/gluon/widget.py", line 746, in start run(options.shell, plain=options.plain, bpython=options.bpython, File "/odindrive/temp/web2pytest/web2py/gluon/shell.py", line 238, in run adir = os.path.absdir(os.path.join('applications', a)) AttributeError: module 'posixpath' has no attribute 'absdir'. Did you mean: 'isdir'? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/59150263-5851-4adc-9645-2f5c12082834n%40googlegroups.com.
[web2py] Re: app not loading external python library
I think this is the same issue as was discussed a few months ago: See this thread: https://groups.google.com/g/web2py/c/xYVWpDGLuzY/m/t9sBabWOAgAJ Seems some issue between the custom importer and the urllib3 module. Can you try once more, but also explicitly pip install *urllib3_secure_extra *in your virtual env? On Thursday, October 26, 2023 at 7:33:25 AM UTC+2 Massimo Di Pierro wrote: > Hello Alex, > > thank for reporting this problem. Is it only occurring with web2py 2.25.1? > > On Monday, 23 October 2023 at 14:05:15 UTC-7 alex wrote: > >> Hi, >> >> I am running web2py Version 2.25.1-stable in virtualenv (python 3.9.5, it >> happens also in python 3.10.10) >> >> After activating the virtualenv, I installed requests >> >> $ pip install request >> $ pip show requests >> Name: requests >> Version: 2.31.0 >> Summary: Python HTTP for Humans. >> Home-page: https://requests.readthedocs.io >> Author: Kenneth Reitz >> Author-email: m...@kennethreitz.org >> License: Apache 2.0 >> Location: >> /Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages >> Requires: certifi, charset-normalizer, idna, urllib3 >> Required-by: >> >> Importing requests from bpython gives no errors. >> >> Importing requests in myapp gives an error. >> I also tried with other external libraries, some of them do work, some >> others cannot be imported. >> >> About this case, I have tried the following: >> >> In "web2py/applications/myapp/models/0.py": >> >> # - - - - - - - - - - - - - - - >> >> # added the virtualenv path to sys.path >> >> site_package_path = >> "/Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages" >> >> if site_package_path not in sys.path: >> sys.path.append(site_package_path) >> >> try: >> import requests >> except: >> raise Exception('import error: "requests" not found') >> >> >> # - - - - - - - - - - - - - - - >> >> I am running web2py with: >> >> $python web2py.py -a 'pwd' >> >> Error log: >> >> # - - - - - - - - - - - - - - - >> Ticket ID >> 127.0.0.1.2023-10-24.05-48-51.a557dcfb-55a3-4063-ac27-879cad8fe799 >> >> import error: "requests" not found >> Version >> web2py™ Version 2.25.1-stable+timestamp.2023.10.08.18.44.43 >> Python Python 3.9.5: /Users/z/dev/web2py/.direnv/python-3.9/bin/python >> (prefix: /Users/z/dev/web2py/.direnv/python-3.9) >> >> ... >> >> Traceback (most recent call last): >> File "/Users/z/dev/web2py/gluon/custom_import.py", line 78, in >> custom_importer >> result = sys.modules[modules_prefix] >> KeyError: 'applications.wh.modules.requests' >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "/Users/z/dev/web2py/applications/wh/models/0.py", line 29, in >> >> import requests >> File "/Users/z/dev/web2py/gluon/custom_import.py", line 80, in >> custom_importer >> raise ImportError("No module named %s" % modules_prefix) >> ImportError: No module named applications.wh.modules.requests >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "/Users/z/dev/web2py/gluon/restricted.py", line 219, in restricted >> exec(ccode, environment) >> File "/Users/z/dev/web2py/applications/wh/models/0.py", line 31, in >> >> raise Exception('import error: "requests" not found') >> Exception: import error: "requests" not found >> Error snapshot help >> Exception(import error: "requests" not found) >> >> inspect attributes >> >> Exception instance attributes >> __cause__ None >> __class__ >> __context__ ImportError('No module named >> applications.wh.modules.requests') >> __delattr__ >> __dict__ {} >> __dir__ >> __doc__ 'Common base class for all non-exit exceptions.' >> __eq__ >> __format__ >> __ge__ >> __getattribute__ >> __gt__ >> __hash__ >> __init__ >> __init_subclass__ >> __le__ >> __lt__ >> __ne__ >> __new__ >> __reduce__ >> __reduce_ex__ >> __repr__ >> __setattr__ >> __setstate__ >> __sizeof__ >> __str__ >> __subclasshook__ >> __suppress_context__ False >> __traceback__ >> args ('import error: "requests" not found',) >> with_traceback >> Frames >> File /Users/z/dev/web2py/gluon/restricted.py in restricted at line 219 >> code arguments variables >> >> File /Users/z/dev/web2py/applications/wh/models/0.py in at line >> 31 code arguments variables >> >> Function argument list >> () >> >> Context locals >> >> ... >> >> >> >> iteritems : >> > >> local_import : >> .> >> myconf : >> {'app': {'name': 'WH', 'author': 'Your Name > 'bootstrap3_inline', 'separator': ''}} >> redirect : >> >> reduce : >> >> request : >> , >> '_custom_import_track_changes': True}> >> response : >> > 'view': 'default/index.html'}> >> session : >> >> site_package_path : >> "'/Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages'" >> sys : >> >> to_bytes : >> >> to_native : >> >> track_changes : >> >> xmlescape : >> >> xrange : >> >> session >>