我是ML的新手。我已经创建了一个面部识别API,并且在本地主机上运行时效果很好,因此我决定将此API托管在linux ubuntu计算机上。当我尝试在浏览器中使用API时,在Apache日志中出现以下错误。
我尝试使用示例烧瓶API来导入sklearn软件包,并将其托管在apache服务器上。它仍然会收到错误。
这是不起作用的代码示例:
from flask import Flask
from sklearn import neighbours
app = Flask(__name__)
@app.route("/")
def hello():
return "It works"
if __name__ == "__main__":
app.run()
我正在使用Apache2作为服务器,python 2.7,flask作为API框架。
请注意,当与python正常运行时,该API在同一Linux服务器上可以正常工作。它仅在apache服务器后才给出此错误。
问题出在哪里,我该如何解决?
这是日志。
[Thu May 23 11:37:19.754459 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] mod_wsgi (pid=5431): Target WSGI script '/home/khanfi/Projects/Flask_Applications/Face_Api/face_api.wsgi' cannot be loaded as Python module.
[Thu May 23 11:37:19.758272 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] mod_wsgi (pid=5431): Exception occurred processing WSGI script '/home/khanfi/Projects/Flask_Applications/Face_Api/face_api.wsgi'.
[Thu May 23 11:37:19.758910 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] Traceback (most recent call last):
[Thu May 23 11:37:19.758947 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] File "/usr/local/lib/python2.7/dist-packages/sklearn/__check_build/__init__.py", line 44, in <module>
[Thu May 23 11:37:19.758958 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] from ._check_build import check_build # noqa
[Thu May 23 11:37:19.758987 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] ImportError: /usr/local/lib/python2.7/dist-packages/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
[Thu May 23 11:37:19.759009 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054]
[Thu May 23 11:37:19.759018 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] During handling of the above exception, another exception occurred:
[Thu May 23 11:37:19.759024 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054]
[Thu May 23 11:37:19.759036 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] Traceback (most recent call last):
[Thu May 23 11:37:19.759073 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] File "/home/khanfi/Projects/Flask_Applications/Face_Api/face_api.wsgi", line 5, in <module>
[Thu May 23 11:37:19.759084 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] from test import app as application
[Thu May 23 11:37:19.759096 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] File "/home/khanfi/Projects/Flask_Applications/Face_Api/test.py", line 2, in <module>
[Thu May 23 11:37:19.759104 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] import sklearn.neighnours
[Thu May 23 11:37:19.759115 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] File "/usr/local/lib/python2.7/dist-packages/sklearn/__init__.py", line 63, in <module>
[Thu May 23 11:37:19.759124 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] from . import __check_build
[Thu May 23 11:37:19.759135 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] File "/usr/local/lib/python2.7/dist-packages/sklearn/__check_build/__init__.py", line 46, in <module>
[Thu May 23 11:37:19.759143 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] raise_build_error(e)
[Thu May 23 11:37:19.759158 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] File "/usr/local/lib/python2.7/dist-packages/sklearn/__check_build/__init__.py", line 41, in raise_build_error
[Thu May 23 11:37:19.759167 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
[Thu May 23 11:37:19.759190 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] ImportError: /usr/local/lib/python2.7/dist-packages/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
[Thu May 23 11:37:19.759214 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] ___________________________________________________________________________
[Thu May 23 11:37:19.759224 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] Contents of /usr/local/lib/python2.7/dist-packages/sklearn/__check_build:
[Thu May 23 11:37:19.759229 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] _check_build.so __init__.py setup.pyc
[Thu May 23 11:37:19.759235 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] __init__.pyc setup.py
[Thu May 23 11:37:19.759241 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] ___________________________________________________________________________
[Thu May 23 11:37:19.759250 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] It seems that scikit-learn has not been built correctly.
[Thu May 23 11:37:19.759256 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054]
[Thu May 23 11:37:19.759262 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] If you have installed scikit-learn from source, please do not forget
[Thu May 23 11:37:19.759267 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] to build the package before using it: run `python setup.py install` or
[Thu May 23 11:37:19.759273 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] `make` in the source directory.
[Thu May 23 11:37:19.759279 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054]
[Thu May 23 11:37:19.759284 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] If you have used an installer, please check that it is suited for your
[Thu May 23 11:37:19.759290 2019] [wsgi:error] [pid 5431:tid 139848295958272] [remote 172.19.204.34:58054] Python version, your operating system and your platform.