Hi Graham , I finally added the lines below in the wsgi script
>>> import nltk >>> nltk.download('stopwords') this created a nltk_data directory at the first run and It now works fine !!!!!!! Thanks a lot for your help. Thanks Eric Le mardi 22 janvier 2019 17:28:37 UTC+1, Eric Demarqui a écrit : > > Libgfortran was also a permission issue : not being accessible by Apache > as well > > I am now facing a similar problem I had when I excuted the first time the > application with Flask/python > > [Tue Jan 22 16:17:16.503173 2019] [wsgi:error] [pid 23077] [remote > 10.222.160.228:37526] Resource\x1b[93mstopwords\x1b[0m not found. > [Tue Jan 22 16:17:16.503176 2019] [wsgi:error] [pid 23077] [remote > 10.222.160.228:37526] Please use the NLTK Downloader to obtain the > resource: > [Tue Jan 22 16:17:16.503178 2019] [wsgi:error] [pid 23077] [remote > 10.222.160.228:37526] > [Tue Jan 22 16:17:16.503183 2019] [wsgi:error] [pid 23077] [remote > 10.222.160.228:37526] \x1b[31m>>> import nltk > [Tue Jan 22 16:17:16.503185 2019] [wsgi:error] [pid 23077] [remote > 10.222.160.228:37526] >>> nltk.download('stopwords') > > At that time, I had to execute under pip3.7 command line > > >>> import nltk > > >>> nltk.download('stopwords') > > > Should I had the same line in the wsgi script ? > > Thanks > Eric > > > Le mardi 22 janvier 2019 17:05:38 UTC+1, Eric Demarqui a écrit : >> >> waoo. great progress Graham ! Thanks for that . >> >> Here is the result of the print in wsgi script : >> [Tue Jan 22 15:31:29.345107 2019] [wsgi:error] [pid 2719] [remote >> 10.222.160.228:36190] >> print(os.listdir('/usr/local/lib/python3.7/site-packages/sklearn')) >> [Tue Jan 22 15:31:29.345121 2019] [wsgi:error] [pid 2719] [remote >> 10.222.160.228:36190] PermissionError: [Errno 13] Permission denied: >> '/usr/local/lib/python3.7/site-packages/sklearn' >> >> most of the directories where owned by root and I assume that httpd >> (running with apache account) was not able to access. >> >> I changed permissions for directories. >> I changed permissions for some .so files (as well) as they were not >> readable. >> >> The most recent problem is now : >> >> [Tue Jan 22 15:57:49.513715 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] importnumpy.core.numeric as _nx >> [Tue Jan 22 15:57:49.513719 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] File >> "/usr/local/lib/python3.7/site-packages/numpy/core/__init__.py", line 26, >> in <module> >> [Tue Jan 22 15:57:49.513722 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] raise ImportError(msg) >> [Tue Jan 22 15:57:49.513731 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] ImportError: >> [Tue Jan 22 15:57:49.513734 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] Importing the multiarray numpy extension module >> failed. Most >> [Tue Jan 22 15:57:49.513737 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] likely you are trying to import a failed build of >> numpy. >> [Tue Jan 22 15:57:49.513739 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] If you're working with a numpy git repo, try `git >> clean -xdf` (removes all >> [Tue Jan 22 15:57:49.513742 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] files not under version control). Otherwise >> reinstall numpy. >> [Tue Jan 22 15:57:49.513744 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] >> [Tue Jan 22 15:57:49.513747 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] Original error was: libgfortran-ed201abd.so.3.0.0: >> cannot open shared object file: No such file or directory >> [Tue Jan 22 15:57:49.513750 2019] [wsgi:error] [pid 14006] [remote >> 10.222.160.228:36858] >> >> not sure where this fortran lib should come from ... >> >> Eric >> >> >> Le mardi 22 janvier 2019 15:50:18 UTC+1, Graham Dumpleton a écrit : >>> >>> It is either going to be an issue with permissions on that package where >>> it is installed, or SELinux is blocking the Apache process from reading >>> anything in that directory. >>> >>> Try adding to your WSGI script before the imports: >>> >>> import os >>> print(os.listdir('/usr/local/lib/python3.7/site-packages/sklearn')) >>> >>> If that errors or shows nothing, would confirm one of the above. >>> >>> On 22 Jan 2019, at 7:45 pm, Eric Demarqui <eric.d...@gmail.com> wrote: >>> >>> Graham, >>> >>> I am getting this : >>> >>> # python3.7 >>> Python 3.7.1 (default, Jan 15 2019, 15:00:56) >>> [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sklearn.feature_extraction >>> /usr/local/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: >>> >>> DeprecationWarning: Using or importing the ABCs from 'collections' instead >>> of from 'collections.abc' is deprecated, and in 3.8 it will stop working >>> from collections import Mapping, defaultdict >>> >>> print(sklearn.feature_extraction.__file__) >>> >>> /usr/local/lib/python3.7/site-packages/sklearn/feature_extraction/__init__.py >>> >>> Thx >>> >>> Le lundi 21 janvier 2019 20:55:11 UTC+1, Graham Dumpleton a écrit : >>>> >>>> From your command line Python interpreter, do: >>>> >>>> import sklearn.feature_extraction >>>> print(sklearn.feature_extraction.__file_) >>>> >>>> What do you get? >>>> >>>> On 22 Jan 2019, at 3:22 am, Eric Demarqui <eric.d...@gmail.com> wrote: >>>> >>>> Thanks Graham, >>>> >>>> let me answer your questions . >>>> >>>> I compiled mod_wsgi from source (from >>>> https://github.com/GrahamDumpleton/mod_wsgi/archive/4.6.5.tar.gz) >>>> My first try was without the python-path in the WSGIDaemonProcess >>>> directive. but the same error was there without python-path. >>>> I am not using a virtual environment. >>>> Here is my python environment : >>>> Python 3.7.1 (default, Jan 15 2019, 15:00:56) >>>> [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux >>>> Type "help", "copyright", "credits" or "license" for more >>>> information. >>>> >>> import sys >>>> >>> sys.path >>>> ['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', >>>> '/usr/local/lib/python3.7/lib-dynload', >>>> '/root/.local/lib/python3.7/site-packages', >>>> '/usr/local/lib/python3.7/site-packages'] >>>> >>> sys.prefix >>>> '/usr/local' >>>> >>> >>>> >>>> is the path ok ? >>>> >>>> I have just tried your suggestion by adding the directive >>>> "WSGIRestrictEmbedded" outside the VirtualHost. >>>> But the same 500 error happens >>>> >>>> [Mon Jan 21 13:51:42.193801 2019] [wsgi:error] [pid 12113] [remote >>>> 10.222.160.228:54376] from sklearn.feature_extraction.text import >>>> TfidfVectorizer >>>> [Mon Jan 21 13:51:42.193829 2019] [wsgi:error] [pid 12113] [remote >>>> 10.222.160.228:54376] ModuleNotFoundError: No module named >>>> 'sklearn.feature_extraction' >>>> >>>> any idea ? >>>> Thanks >>>> Eric >>>> >>>> Le lundi 21 janvier 2019 12:35:56 UTC+1, Graham Dumpleton a écrit : >>>>> >>>>> >>>>> >>>>> On 21 Jan 2019, at 9:58 pm, Eric Demarqui <eric.d...@gmail.com> wrote: >>>>> >>>>> Hi >>>>> >>>>> I have an application using Flask server which is running fine. >>>>> >>>>> I want to use now Apache with mod_wsgi on this environment : >>>>> Apache/2.4.6 (Red Hat Enterprise Linux) mod_wsgi/4.6.5 Python/3.7 >>>>> >>>>> Here is how my wsgi.conf file looks like : >>>>> >>>>> <VirtualHost *> >>>>> ServerName xxxxxx >>>>> >>>>> WSGIDaemonProcess pythonapi user=apache group=apache processes=1 >>>>> threads=5 home=/var/www/html/pythonapi >>>>> python-path=/usr/local/lib/python3.7/site-packages >>>>> >>>>> >>>>> Are you using system package for mod_wsgi, or are you compiling from >>>>> source code yourself? The system mod_wsgi package is not going to be for >>>>> Python 3.7. You would need to uninstall the system package to be able to >>>>> compile mod_wsgi from source code. So how did you install mod_wsgi? >>>>> >>>>> Next issue is that you shouldn’t use python-path to refer to a >>>>> site-packages directory like that, especially not one in the actual >>>>> Python >>>>> installation. If you need to be referring to the one for the actual >>>>> Python >>>>> installation, it generally indicates something is wrong with your setup. >>>>> >>>>> If using a Python virtual environment you should be using python-home. >>>>> See: >>>>> >>>>> >>>>> https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html >>>>> >>>>> Even if not using a virtual environment. If the Python is in a non >>>>> standard location, you should also use python-home but in that case >>>>> referring to sys.path value for the main Python installation and not that >>>>> of a virtual environment. >>>>> >>>>> I would suggest though when using daemon mode, to add at global scope >>>>> outside of the VirtualHost: >>>>> >>>>> WSGIRestrictEmbedded On >>>>> >>>>> This ensures you are using daemon mode. >>>>> >>>>> So first up, it looks a bit like you are mixing mod_wsgi compiled for >>>>> one Python version/installation, with a different Python version or >>>>> virtual >>>>> environment created from a different version. >>>>> >>>>> Beyond that, because you are RHEL, it could be a SELinux issue, but >>>>> first confirm how your mod_wsgi is installed. >>>>> >>>>> WSGIProcessGroup pythonapi >>>>> >>>>> WSGIScriptAlias /servicebotpy >>>>> /var/www/html/pythonapi/servicebotpy.wsgi >>>>> >>>>> <Directory /var/www/html/pythonapi> >>>>> WSGIApplicationGroup %{GLOBAL} >>>>> Options Indexes MultiViews FollowSymlinks >>>>> AllowOverride None >>>>> Require all granted >>>>> </Directory> >>>>> </VirtualHost> >>>>> >>>>> mod_wsgi is compiled with same version as of python3.7 >>>>> >>>>> I am stucked here . >>>>> >>>>> [Mon Jan 21 10:32:45.881625 2019] [wsgi:error] [pid 22328] [remote >>>>> 10.222.160.228:49260] File "/var/www/html/pythonapi/scorer.py", >>>>> line 5, in <module> >>>>> [Mon Jan 21 10:32:45.881632 2019] [wsgi:error] [pid 22328] [remote >>>>> 10.222.160.228:49260] from sklearn.feature_extraction.text import >>>>> TfidfVectorizer >>>>> [Mon Jan 21 10:32:45.881656 2019] [wsgi:error] [pid 22328] [remote >>>>> 10.222.160.228:49260] ModuleNotFoundError: No module named >>>>> 'sklearn.feature_extraction' >>>>> >>>>> Thanks for help >>>>> Eric >>>>> >>>>> >>>>> -- >>>>> 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 modwsgi+u...@googlegroups.com. >>>>> To post to this group, send email to mod...@googlegroups.com. >>>>> Visit this group at https://groups.google.com/group/modwsgi. >>>>> For more options, visit 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 modwsgi+u...@googlegroups.com. >>>> To post to this group, send email to mod...@googlegroups.com. >>>> Visit this group at https://groups.google.com/group/modwsgi. >>>> For more options, visit 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 modwsgi+u...@googlegroups.com. >>> To post to this group, send email to mod...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/modwsgi. >>> For more options, visit 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 modwsgi+unsubscr...@googlegroups.com. To post to this group, send email to modwsgi@googlegroups.com. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.