熊猫:无法使用mod_wsgi导入numpy

时间:2019-03-04 12:15:23

标签: pandas python-3.6 centos7 mod-wsgi

我已经安装了熊猫以及相关性,并且可以从命令行导入-

[root@ip-172-16-6-131 ~]# python3.6 
Python 3.6.6 (default, Jan 24 2019, 07:48:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> pandas.__version__
'0.23.4'

其他信息

Version-
Python=3.6.6
Pip=19.0.1
Pandas=0.23.4
Httpd=2.4.6
mod_Wsgi=3.4
OS=CentOS Linux release 7.6.1810 

使用mod wsgi导入熊猫时出现错误-

ImportError: Missing required dependencies ['numpy']
ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app 
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/var/app/dealer-reco-engine-qa/hello.py", line 22, in hello1
import pandas
File "/usr/local/lib/python3.6/site-packages/pandas/__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))<br> [Mon Mar 04 11:49:59.839292 2019] [:error] [pid 31771] [client ::1:43918] 
ImportError: Missing required dependencies ['numpy']

Numpy也已安装-

  
    
      

导入numpy       numpy。版本       '1.15.4'

    
  

下面是httpd conf文件-

    WSGIPythonPath /usr/local/lib/python3.6/site-packages/
    <VirtualHost *>
        ServerName test.com

        ErrorLog "/var/log/httpd/test_error_log"
        CustomLog "/var/log/httpd/test_access_log" combined
        WSGIScriptAlias / /var/app/test-qa/test.wsgi
        WSGIScriptReloading On
        <Directory /var/app/test-qa/>
            Require all granted
        </Directory>
    </VirtualHost>

wsgi文件-

    import sys
    sys.path.insert(0, '/path/to/test-qa/')
    from myapp import app as application

cat /path/to/test-qa/my.app

    #!/usr/bin/python
    from flask import Flask
    app = Flask(__name__)

    @app.route("/")
    def test():
        import pandas
        return "Checking pandas if install.."

    if __name__ == "__main__":
        app.run(host='0.0.0.0', port=8000)

0 个答案:

没有答案