BinBashBanana / PyDodge

Python HTTP Proxy w/ Rewrites (PyDodge "B") https://github.com/webrecorder/pywb
GNU General Public License v3.0
25 stars 63 forks source link

problem with greenlet #24

Closed h4mid007 closed 1 year ago

h4mid007 commented 1 year ago

Ubuntu 20.04.5 Python 3.8.10

I have cloned the repo, then executing run.bash throws following error:

Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/gevent/__init__.py", line 86, in <module> from gevent._hub_local import get_hub File "/usr/local/lib/python3.8/dist-packages/gevent/_hub_local.py", line 101, in <module> import_c_accel(globals(), 'gevent.__hub_local') File "/usr/local/lib/python3.8/dist-packages/gevent/_util.py", line 148, in import_c_accel mod = importlib.import_module(cname) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "src/gevent/_hub_local.py", line 1, in init gevent._gevent_c_hub_local ValueError: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 152 from C header, got 40 from PyObject

BinBashBanana commented 1 year ago

Did you run pip install -r requirements.txt?

h4mid007 commented 1 year ago

Did you run pip install -r requirements.txt?

Of course, All requirements satisfied from requirements.txt.

P.S. Since this error came from 'gevent' package, I updated gevent to latest version (20.9.0 -> 22.10.2), gevent problem fixed but came into a new one:

*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 2212928 bytes (2161 KB) for 100 cores
*** Operational MODE: async ***
Traceback (most recent call last):
  File "/root/PyDodge/./pywb/apps/wayback.py", line 2, in <module>
    from pywb.apps.frontendapp import FrontEndApp
  File "/root/PyDodge/./pywb/apps/frontendapp.py", line 23, in <module>
    from pywb.rewrite.templateview import BaseInsertView
  File "/root/PyDodge/./pywb/rewrite/templateview.py", line 8, in <module>
    from jinja2 import Environment, TemplateNotFound, contextfunction, select_autoescape
  File "/usr/lib/python3/dist-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 15, in <module>
    from jinja2 import nodes
  File "/usr/lib/python3/dist-packages/jinja2/nodes.py", line 23, in <module>
    from jinja2.utils import Markup
  File "/usr/lib/python3/dist-packages/jinja2/utils.py", line 656, in <module>
    from markupsafe import Markup, escape, soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/dist-packages/markupsafe/__init__.py)
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***

And this occurs because the soft_unicode method has been deprecated in markupsafe version 2.1.0. Falling back to markupsafe 2.0.1 (which has soft_unicode method) gives another incompatibility: werkzeug 2.2.2 has requirement MarkupSafe>=2.1.1, but you have markupsafe 2.0.1 which is incompatible.

🤔

BinBashBanana commented 1 year ago

This version is getting old, I should probably add exact versions to requirements.txt. I should also mention that this project is deprecated. All I can suggest is using an older version of werkzeug.

cse0001 commented 8 months ago

The root cause with your issue stems from a dependency management conflict between two software ecosystems. According to the error message, your 'markupsafe' was installed using 'pip' at the path /usr/local/lib/python3.8/dist-packages/markupsafe/. The 'jinja2' that depends on it was installed using 'apt' at the path /usr/lib/python3/dist-packages/jinja2. The versions of the two are not compatible. In fact, there is a version of 'markupsafe' in the system that 'jinja2' correctly depends on, but the Python interpreter prioritizes the 'markupsafe' installed by 'pip', leading to this issue. There are typically two solutions to this problem: (1) Use 'pip' to uninstall markupsafe, and then reinstall it using 'apt', or uninstall 'jinja2' using 'apt' and reinstall it using 'pip'. (2) Use Python's imp module to customize the path and import the 'markupsafe' from the 'apt' path before importing 'jinja2'. An example is as follows:

import imp
path = ['/usr/lib/python3/dist-packages']
fp, pathname, description = imp.find_module('markupsafe', path)
imp.load_module("markupsafe", fp, pathname, description)

Hope my diagnosis is helpful to you! @h4mid007