Hi to all,

to start experimenting with py4web in Eclipse/PyDev on Debian Linux I did 
the following. 
Maybe someone will find it useful. 

Debugging is not working yet for me, an advice would be welcome.

1) Set-up the virtual environment for web4py with libraries managed by pip 
(to avoid mixing with system-wide python libraries installed by the Debian 
packaging system):

sudo apt-get install virtualenvwrapper
pip3 install --user --upgrade virtualenvwrapper
mkvirtualenv -p /usr/bin/python3 /opt/python3env/py4web
cd /opt/python3env/py4web/bin

2) Install py4web by pip.

./pip3 install py4web
./python3 -c "from pydal.validators import CRYPT; 
open('/opt/py4web/password.txt','w').write(str(CRYPT()(input('password:'))[0]))"

Test if it is working:

./py4web-start /opt/py4web -p /opt/py4web/password.txt

3) Create a new PyDev project for the whole py4web apps directory:

Start Eclipse, create a new PyDev project with the source directory /opt/py4web 


Define the interpreter /opt/python3env/py4web/bin/python3 for the project; 
in its definition at first add the system libraries:

/opt/python3env/py4web/lib/python3.7 
/opt/python3env/py4web/lib/python3.7/lib-dynload 
/opt/python3env/py4web/lib/python3.7/site-packages

As a result, PyDev complained: "It seems that the Python /Lib folder (which 
contains the standard library) was not found /selected during the instal 
process. This folder (which contains files such as threading.py and 
traceback.py) is required for PyDev to function properly ...". To solve it, 
at first I tried symlinking the mentioned files:

ln -s /usr/lib/python3.7/threading.py 
/opt/python3env/py4web/lib/threading.py
ln -s /usr/lib/python3.7/traceback.py 
/opt/python3env/py4web/lib/traceback.py

The complaint has disappeared and I have not noticed any other apparent 
problems. However, to be sure that everything needed is available, later I 
added the whole /usr/lib/python3.7 in libraries instead of the symlinked 
files.
Because only system libraries are imported and not site-packages, hopefully 
this second solution won't break the virtualenv separation from the system 
environment.

4) Enable launching py4web from Eclipse:

Copy web4py starting script to the apps directory:

cp /opt/python3env/py4web/bin/py4web-start /opt/py4web/py4web-start.py

Define new run configuration for py4web-start.py with the arguments 
"/opt/py4web 
-p /opt/py4web/password.txt".

Now I can start py4web from Eclipse and read its output in the Eclipse 
console.

5) PyDev Debugging:

However, for now, I got stuck in making the PyDev debugger working. It 
complains:

pydev debugger: starting (pid: 27370)
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in 
_call_with_frames_removed
  File 
"/opt/python3env/py4web/lib/python3.7/site-packages/py4web/__init__.py", 
line 1, in <module>
    from . core import (
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 152, in __exit__
  File "<frozen importlib._bootstrap>", line 107, in release
RuntimeError: cannot release un-acquired lock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in 
_call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 152, in __exit__
  File "<frozen importlib._bootstrap>", line 107, in release
RuntimeError: cannot release un-acquired lock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 3090, in <module>
    main()
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 3083, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 2154, in run
    return self._exec(is_module, entry_point_fn, module_name, file, 
globals, locals)
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 2161, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/_pydev_imps/_pydev_execfile.py",
 
line 25, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/opt/py4web/py4web-start.py", line 3, in <module>
    from py4web.core import main
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 152, in __exit__
  File "<frozen importlib._bootstrap>", line 107, in release
RuntimeError: cannot release un-acquired lock

With regards,
David

-- 
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/45471aa3-ea5a-4f7e-96ce-a6e5b3777ef5%40googlegroups.com.

Reply via email to