You haven't shown your Apache configuration for mod_wsgi.
You need to tell mod_wsgi/Python that your virtual environment is at:
/var/www/mywebsite.com/flask <http://mywebsite.com/flask>
Adding that directory to sys.path is not enough.
Read:
http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html
<http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html>
as it explains what you need to do.
I can't be more specific since you didn't include the Apache configuration for
mod_wsgi.
Graham
> On 12 Jul 2018, at 9:45 am, jerry100 <[email protected]> wrote:
>
> Hello all! The requests module was installed in the site-packages folder in
> the virtual environment as I expected. I ran "pip install requests". Since I
> run the flask app on apache and the virtual environment is inactive, by
> design, as we are using mod_wsgi, the requests module is not being imported
> by Apache.
>
> /var/www/mywebsite.com/flask/lib/python3.6/site-packages/requests
>
> This is how I am trying to import the module:
>
> from flask import Flask, render_template, request
> import requests
>
>
> Here's my flask.wsgi file. Are we supposed to import modules in this file
> instead of init.py file?
>
> import sys
>
> sys.path.insert(0, "/var/www/mywebsite.com/flask/")
>
> from init import app as application
>
>
> This is the error I get. What am I doing wrong?
>
> [Wed Jul 11 16:16:18.941771 2018] [wsgi:error] [pid 7244] [client
> 192.168.1.2:64794] Traceback (most recent call last):
> [Wed Jul 11 16:16:18.941850 2018] [wsgi:error] [pid 7244] [client
> 192.168.1.2:64794] File "/var/www/mywebsite.com/flask/flask.wsgi", line 5,
> in <module>
> [Wed Jul 11 16:16:18.941864 2018] [wsgi:error] [pid 7244] [client
> 192.168.1.2:64794] from init import app as application
> [Wed Jul 11 16:16:18.941876 2018] [wsgi:error] [pid 7244] [client
> 192.168.1.2:64794] File "/var/www/mywebsite.com/flask/init.py", line 2, in
> <module>
> [Wed Jul 11 16:16:18.941881 2018] [wsgi:error] [pid 7244] [client
> 192.168.1.2:64794] import requests
> [Wed Jul 11 16:16:18.941909 2018] [wsgi:error] [pid 7244] [client
> 192.168.1.2:64794] ModuleNotFoundError: No module named 'requests'
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.