Instead then. Print out sys.path from the interpreter and then also from your WSGI script file.
> On 14 Jun 2018, at 3:56 pm, Rajeev Jain <[email protected]> wrote: > > root is not enabled. but i guess i can enable it for testing purposes. > > On Jun 13, 2018, at 10:55 PM, Graham Dumpleton <[email protected] > <mailto:[email protected]>> wrote: > > From root, can you su to the user for Apache and try the same thing. > > Graham > >> On 14 Jun 2018, at 3:54 pm, Rajeev Jain <[email protected] >> <mailto:[email protected]>> wrote: >> >> yes. >> >> /etc/apache2/sites-available$ python >> Python 3.6.5 (default, May 3 2018, 10:08:28) >> [GCC 5.4.0 20160609] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import datetime >> >>> >> >> —Rajeev >> >> >> >> On Jun 13, 2018, at 10:52 PM, Graham Dumpleton <[email protected] >> <mailto:[email protected]>> wrote: >> >> Odd. >> >> If you run python3.6 and enter in the interpreter: >> >> import datetime >> >> it works? >> >> Graham >> >>> On 14 Jun 2018, at 3:50 pm, 'Rajeev Jain' via modwsgi >>> <[email protected] <mailto:[email protected]>> wrote: >>> >>> >>> On Jun 13, 2018, at 10:42 PM, Graham Dumpleton <[email protected] >>> <mailto:[email protected]>> wrote: >>> >>> How did you install Python 3.6? >>> >>> followed instructions here: >>> https://askubuntu.com/questions/889535/how-to-install-pip-for-python-3-6-on-ubuntu-16-10 >>> >>> <https://askubuntu.com/questions/889535/how-to-install-pip-for-python-3-6-on-ubuntu-16-10> >>> >>> Let's suppose that you have a system running Ubuntu 16.04, 16.10, or 17.04, >>> and you want Python 3.6 to be the default Python. >>> >>> If you're using Ubuntu 16.04 LTS, you'll need to use a PPA: >>> >>> sudo add-apt-repository ppa:jonathonf/python-3.6 # (only for 16.04 LTS) >>> Then, run the following (this works out-of-the-box on 16.10 and 17.04): >>> >>> sudo apt update >>> sudo apt install python3.6 >>> sudo apt install python3.6-dev >>> sudo apt install python3.6-venv >>> wget https <https://bootstrap.pypa.io/get-pip.py>:// >>> <https://bootstrap.pypa.io/get-pip.py>bootstrap >>> <https://bootstrap.pypa.io/get-pip.py>. >>> <https://bootstrap.pypa.io/get-pip.py>pypa >>> <https://bootstrap.pypa.io/get-pip.py>. >>> <https://bootstrap.pypa.io/get-pip.py>io >>> <https://bootstrap.pypa.io/get-pip.py>/ >>> <https://bootstrap.pypa.io/get-pip.py>get >>> <https://bootstrap.pypa.io/get-pip.py>- >>> <https://bootstrap.pypa.io/get-pip.py>pip >>> <https://bootstrap.pypa.io/get-pip.py>. >>> <https://bootstrap.pypa.io/get-pip.py>py >>> <https://bootstrap.pypa.io/get-pip.py> >>> sudo python3.6 get-pip.py >>> sudo ln -s /usr/bin/python3.6 /usr/local/bin/python3 >>> sudo ln -s /usr/local/bin/pip /usr/local/bin/pip3 >>> >>> # Do this only if you want python3 to be the default Python >>> # instead of python2 (may be dangerous, esp. before 2020): >>> # sudo ln -s /usr/bin/python3.6 /usr/local/bin/python >>> When you have completed all of the above, each of the following shell >>> commands should indicate Python 3.6.1 (or a more recent version of Python >>> 3.6): >>> >>> python --version # (this will reflect your choice, see above) >>> python3 --version >>> $(head -1 `which pip` | tail -c +3) --version >>> $(head -1 `which pip3` | tail -c +3) --version >>> >>> >>> This is running on a local Ubuntu 16.04 computer. >>> >>> python >>> Python 3.6.5 (default, May 3 2018, 10:08:28) >>> [GCC 5.4.0 20160609] on linux >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> import math >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> Unless that is a very up to date Ubuntu version, which I would doubt AWS >>> would be using if this is one of their images, you would need to install it >>> from source code. Installing Python from source code yourself can be a bit >>> tricky on Linux as the default configure options aren't what you need. Also >>> not a good idea to install from Python source code into system directories >>> as it is then hard to extract it out if you need to remove it. >>> >>>> On 14 Jun 2018, at 3:33 pm, Rajeev Jain <[email protected] >>>> <mailto:[email protected]>> wrote: >>>> >>>> Latest update: >>>> >>>> No virtual environment. Python3.6 is now installed into the system folder: >>>> >>>> python location: >>>> /etc/apache2/sites-available$ python --version >>>> Python 3.6.5 >>>> >>>> python >>>> Python 3.6.5 (default, May 3 2018, 10:08:28) >>>> [GCC 5.4.0 20160609] on linux >>>> Type "help", "copyright", "credits" or "license" for more information. >>>> >>> import sys >>>> >>> print(sys.prefix) >>>> /usr >>>> >>>> Flask location: >>>> >>> import flask >>>> >>> print(flask.__file__) >>>> /usr/local/lib/python3.6/dist-packages/flask/__init__.py >>>> >>>> mod_wsgi-express module-config >>>> LoadModule wsgi_module >>>> "/usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so" >>>> WSGIPythonHome "/usr" >>>> >>>> cat wsgi.load >>>> LoadModule wsgi_module >>>> /usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so >>>> >>>> >>>> /etc/apache2/sites-available$ cat FlaskApp.conf >>>> <VirtualHost *:83> >>>> >>>> ServerName flaskapp.com <http://flaskapp.com/> >>>> >>>> WSGIDaemonProcess flaskapp.com <http://flaskapp.com/> python-home=/usr >>>> python-path=/var/www/FlaskApp >>>> >>>> WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi >>>> process-group=flaskapp.com <http://flaskapp.com/> >>>> application-group=%{GLOBAL} >>>> >>>> <Directory /var/www/FlaskApp/> >>>> <Files flaskapp.wsgi> >>>> Require all granted >>>> </Files> >>>> </Directory> >>>> >>>> </VirtualHost> >>>> >>>> /etc/apache2/mods-available$ cat wsgi.conf >>>> <IfModule mod_wsgi.c> >>>> >>>> WSGIRestrictEmbedded On >>>> >>>> </IfModule> >>>> >>>> Testing: >>>> curl -sH 'Host: flaskapp.com <http://flaskapp.com/>' localhost:83|grep >>>> title >>>> <title>500 Internal Server Error</title> >>>> >>>> tail -l /var/log/apache2/error.log >>>> [Wed Jun 13 22:18:08.678744 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] from werkzeug.exceptions import abort >>>> [Wed Jun 13 22:18:08.678749 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] File >>>> "/usr/local/lib/python3.6/dist-packages/werkzeug/__init__.py", line 151, >>>> in <module> >>>> [Wed Jun 13 22:18:08.678752 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] __import__('werkzeug.exceptions') >>>> [Wed Jun 13 22:18:08.678756 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] File >>>> "/usr/local/lib/python3.6/dist-packages/werkzeug/exceptions.py", line 67, >>>> in <module> >>>> [Wed Jun 13 22:18:08.678759 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] from werkzeug._internal import _get_environ >>>> [Wed Jun 13 22:18:08.678764 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] File >>>> "/usr/local/lib/python3.6/dist-packages/werkzeug/_internal.py", line 15, >>>> in <module> >>>> [Wed Jun 13 22:18:08.678766 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] from datetime import datetime, date >>>> [Wed Jun 13 22:18:08.678771 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] File "/usr/lib/python3.6/datetime.py", line 8, in >>>> <module> >>>> [Wed Jun 13 22:18:08.678773 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] import math as _math >>>> [Wed Jun 13 22:18:08.678786 2018] [wsgi:error] [pid 3095] [remote >>>> 127.0.0.1:57590] ModuleNotFoundError: No module named 'math' >>>> >>>> Running FlaskApp on its own: >>>> /var/www/FlaskApp/FlaskApp$ python __init__.py >>>> * Serving Flask app "__init__" (lazy loading) >>>> * Environment: production >>>> WARNING: Do not use the development server in a production environment. >>>> Use a production WSGI server instead. >>>> * Debug mode: off >>>> * Running on http://127.0.0.1:5000/ <http://127.0.0.1:5000/> (Press >>>> CTRL+C to quit) >>>> 127.0.0.1 - - [13/Jun/2018 22:25:23] "GET / HTTP/1.1" 200 - >>>> 127.0.0.1 - - [13/Jun/2018 22:25:23] "GET /favicon.ico HTTP/1.1" 404 - >>>> >>>> curl -sH 'Host: flaskapp.com <http://flaskapp.com/>' localhost:5000 >>>> Hello, this is running from flasK! >>>> >>>> As you can see the FlaskApp is running fine. >>>> Python and all modules are now installed in system locations and they are >>>> running fine. >>>> Apache2 is running fine. I have 2 other virtualhosts running serving >>>> php/html pages >>>> >>>> Still WSGI is still not setup correctly. >>>> >>>> I'm shocked at the lack of decent documentation to get WCGI enabled on a >>>> Apache2 server. What am I missing?? >>> >>> There is a whole web site on it at: >>> >>> http://modwsgi.readthedocs.io/en/develop/ >>> <http://modwsgi.readthedocs.io/en/develop/> >>> >>> It just doesn't cover the specifics of particular ways that Linux distros >>> need things done because they depart from standard conventions for Apache >>> and do things their own way. Lot of work to document how every different >>> Linux distro does it. >>> >>>> Don't you have some basic test code or files one can run to verify the >>>> WSGI is setup correctly? >>> >>> Usually if you can get the WSGI hello world program working you are good. >>> >>> * >>> http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html >>> >>> <http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html> >>> >>> There are various checks you can run in: >>> >>> * >>> http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html >>> >>> <http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html> >>> >>> This more for when debugging issues when things don't work. >>> >>> Graham >>> >>>> >>>> Please advise. >>>> --Rajeev >>>> >>>> >>>> >>>> >>>> -- >>>> 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] >>> <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] >>> <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] >> <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] >> <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] > <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] > <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.
