0

I'm trying to switch my flask WSGI application from CPython to Pypy, so I've set up a nex virtual env using pypy3 -m venv VENV_DIRECTORY.

Then activated the venv and installed the dependencies using pip. When I start the python console and write import flask, it works properly.

Then I've changed the python-home property in my Apache configuration site to use this new venv and reload the apache service. While reloading the website, there is 500 error and when I looked into the apache error log, it's written that there is no module named flask.

So can I really use Pypy to work with mod_wsgi and if not, why?

And if yes, then how can I do that?

Thank you all.

Aditya
  • 783
  • 1
  • 8
  • 25
  • It sounds like it is either using a different python executable or it’s using the correct python executable but isn’t finding the libraries installed in your venv. Can you print out the contents of `sys.path` before the error? Can you output the contents of `python-home`? When your venv is activated and you enter `which python`, does it show a python executable in a folder that you added to python-home? What operating system are you using (python-home doesn’t work on Windows)? – BenjaminGolder Jan 16 '20 at 10:02
  • When I enter `which python`, it tells me that the right python binary is used. But when I print the `sys.path` result of the WSGI app (found in the apache error log), this is what I get : `['/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload']`. So why it uses the right binary when using CPython venv and not when using PyPy ? How can I resolve that ? – lepompiste Jan 16 '20 at 18:38
  • And I'm using Debian 10 – lepompiste Jan 16 '20 at 18:55
  • It seems like your `python-home` configuration may not be successfully changing the directory. What is the value you used for `python-home`? Do you see that value listed in the directories listed in `sys.path`? Are you able to output environmental variables into the Apache error log? Can you see any values for `PATH`, `PYTHON_PATH`, or `PYTHON_HOME`? – BenjaminGolder Jan 17 '20 at 01:57
  • I had to add python-path property in the Apache conf, and then it worked, I don't know why it wasn't working without. But then, another problem came to me : bcrypt python module wasn't working. Even if it imports properly when I use the python Pypy console, it wasn't when using mod_wsgi. I don't know why and after some researches, it seems that mod_wsgi isn't compatible with Pypy. So i abandoned the idea of using Pypy with mod_wsgi (it seems that uWSGI is compatible with Pypy). Thank you for your help ! – lepompiste Jan 23 '20 at 18:27

0 Answers0