Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
虽然裸python烧瓶启动成功,但我的uwsgi启动失败,出现奇怪的python库导入错误_Python_Flask_Uwsgi - Fatal编程技术网

虽然裸python烧瓶启动成功,但我的uwsgi启动失败,出现奇怪的python库导入错误

虽然裸python烧瓶启动成功,但我的uwsgi启动失败,出现奇怪的python库导入错误,python,flask,uwsgi,Python,Flask,Uwsgi,我用uwsgi托管的PythonFlask框架开发了一个Web服务器。它在一台计算机上运行良好,当我将它移植到另一台配置完全相同的计算机上时,即Ubuntu 16.04、python 2.7、uwsgi 2.0,但uwsgi由于奇怪的导入错误而失败 我可以使用裸python命令行成功启动web服务,如下所示 python HelloCityEye.py 服务启动时,一切正常 # python HelloCityEye.py /usr/local/lib/python2.7/dist-p

我用uwsgi托管的PythonFlask框架开发了一个Web服务器。它在一台计算机上运行良好,当我将它移植到另一台配置完全相同的计算机上时,即Ubuntu 16.04、python 2.7、uwsgi 2.0,但uwsgi由于奇怪的导入错误而失败

我可以使用裸python命令行成功启动web服务,如下所示

python HelloCityEye.py
服务启动时,一切正常

    # python HelloCityEye.py
/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py:835: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
2019-09-12 16:09:27,129 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2019-09-12 16:09:27,129 INFO sqlalchemy.engine.base.Engine ()
2019-09-12 16:09:27,130 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2019-09-12 16:09:27,130 INFO sqlalchemy.engine.base.Engine ()
2019-09-12 16:09:27,131 INFO sqlalchemy.engine.base.Engine PRAGMA main.table_info("users")
2019-09-12 16:09:27,131 INFO sqlalchemy.engine.base.Engine ()
 * Serving Flask app "HelloCityEye" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py:835: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
2019-09-12 16:09:27,690 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2019-09-12 16:09:27,691 INFO sqlalchemy.engine.base.Engine ()
2019-09-12 16:09:27,691 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2019-09-12 16:09:27,691 INFO sqlalchemy.engine.base.Engine ()
2019-09-12 16:09:27,692 INFO sqlalchemy.engine.base.Engine PRAGMA main.table_info("users")
2019-09-12 16:09:27,692 INFO sqlalchemy.engine.base.Engine ()
 * Debugger is active!
 * Debugger PIN: 102-535-023
我可以使用任何web浏览器访问我的web服务

然后我想用uwsgi框架托管flask web服务,如下配置为temp.ini文件(与以前的工作计算机相同)

但是,当我尝试使用以下命令启动uwsgi时

# ./bin/uwsgi temp.ini
错误消息跳转到python问题中

(cityeye) root@ubuntu:/home/gongming/pythonwork/cityeye# ./bin/uwsgi temp.ini
[uWSGI] getting INI configuration from temp.ini
*** Starting uWSGI 2.0.12 (64bit) on [Thu Sep 12 16:44:06 2019] ***
compiled with version: 4.8.4 on 02 May 2016 17:58:33
os: Linux-4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018
nodename: ubuntu
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/gongming/pythonwork/cityeye
detected binary path: /home/gongming/pythonwork/cityeye/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
chdir() to /home/gongming/pythonwork/cityeye
your processes number limit is 1903
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 127.0.0.1:9090 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:45929 (port auto-assigned) fd 3
Python version: 2.7.15rc1 (default, Nov 12 2018, 14:31:15)  [GCC 7.3.0]
Set PythonHome to /home/gongming/pythonwork/cityeye
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x11b0f90
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1527960 bytes (1492 KB) for 20 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "./HelloCityEye.py", line 9, in <module>
    import Earth2Mars  # coordinate transformation
  File "./Earth2Mars.py", line 12, in <module>
    import numpy as np
  File "/home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/__init__.py", line 201, in <module>
    from . import random
  File "/home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/random/__init__.py", line 99, in <module>
    from .mtrand import *
ImportError: /home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/random/mtrand.so: undefined symbol: PyFPE_jbuf
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 10716)
...
spawned uWSGI worker 20 (pid: 10737, cores: 1)
spawned uWSGI http 1 (pid: 10738)
(城市眼)root@ubuntu:/home/gongming/pythonwork/cityeye#/bin/uwsgi temp.ini
[uWSGI]从temp.INI获取INI配置
***于[2019年9月12日星期四16:44:06]启动uWSGI 2.0.12(64位)***
使用版本:4.8.4于2016年5月2日17:58:33编译
操作系统:Linux-4.15.0-20-generic#21 Ubuntu SMP周二4月24日06:16:15 UTC 2018
nodename:ubuntu
机器:x86_64
时钟来源:unix
检测到的CPU内核数:1
当前工作目录:/home/gongming/pythonwork/cityeye
检测到的二进制路径:/home/gongming/pythonwork/cityeye/bin/uwsgi
!!! 无内部路由支持,使用pcre支持重建!!!
将setgid()设置为33
setuid()到33
chdir()到/home/gongming/pythonwork/cityeye
您的进程数限制为1903
您的内存页大小为4096字节
检测到的最大文件描述符编号:1024
锁引擎:pthread健壮互斥体
thunder lock:已禁用(可以使用--thunder lock启用)
uWSGI http绑定在127.0.0.1:9090 fd 4上
uwsgi套接字0绑定到TCP地址127.0.0.1:45929(端口自动分配)fd 3
Python版本:2.7.15rc1(默认值,2018年11月12日,14:31:15)[GCC 7.3.0]
将PythonHome设置为/home/gongming/pythonwork/cityeye
***Python线程支持已禁用。您可以使用--enable threads来启用它***
Python主解释器在0x11b0f90处初始化
您的服务器套接字侦听积压限制为100个连接
你对工人的仁慈是60秒
为20个核心映射了1527960字节(1492 KB)
***操作模式:预工作***
回溯(最近一次呼叫最后一次):
文件“/HelloCityEye.py”,第9行,在
导入Earth2Mars#坐标变换
文件“/Earth2Mars.py”,第12行,在
将numpy作为np导入
文件“/home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/_-init___.py”,第201行,in
从…起随机输入
文件“/home/gongming/pythonwork/cityeye/local/lib/python2.7/site packages/numpy/random/_init__.py”,第99行,在
从.mtrand导入*
导入错误:/home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/random/mtrand.so:未定义符号:PyFPE_jbuf
无法加载应用0(装入点=“”)(找不到可调用或导入错误)
***没有加载应用程序。以全动态模式运行***
***uWSGI以多解释器模式运行***
衍生的uWSGI主进程(pid:10716)
...
繁殖的uWSGI工作者20(pid:10737,核心数:1)
生成的uWSGI http 1(pid:10738)
即使我重新安装了numpy软件包,也没有任何帮助

我确信它不应该是python库,因为我不仅可以直接用python运行它,而不用uwsgi托管,而且我还可以在另一台ubuntu计算机上使用uwsgi,而不会出现任何问题

那么,是什么导致了这些错误呢


感谢您的关注。

可能是多处理(
processs=20
)导致了此问题。uwsgi创建一个应用程序对象并将其分叉。这可能会导致数据库连接失败等。请尝试将
lazy-app=true
添加到您的uwsgi配置中,看看是否有帮助。我尝试了您的方法,添加
lazy-app=true
,减少甚至删除
进程,但错误与以前相同。
(cityeye) root@ubuntu:/home/gongming/pythonwork/cityeye# ./bin/uwsgi temp.ini
[uWSGI] getting INI configuration from temp.ini
*** Starting uWSGI 2.0.12 (64bit) on [Thu Sep 12 16:44:06 2019] ***
compiled with version: 4.8.4 on 02 May 2016 17:58:33
os: Linux-4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018
nodename: ubuntu
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/gongming/pythonwork/cityeye
detected binary path: /home/gongming/pythonwork/cityeye/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
chdir() to /home/gongming/pythonwork/cityeye
your processes number limit is 1903
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 127.0.0.1:9090 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:45929 (port auto-assigned) fd 3
Python version: 2.7.15rc1 (default, Nov 12 2018, 14:31:15)  [GCC 7.3.0]
Set PythonHome to /home/gongming/pythonwork/cityeye
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x11b0f90
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1527960 bytes (1492 KB) for 20 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "./HelloCityEye.py", line 9, in <module>
    import Earth2Mars  # coordinate transformation
  File "./Earth2Mars.py", line 12, in <module>
    import numpy as np
  File "/home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/__init__.py", line 201, in <module>
    from . import random
  File "/home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/random/__init__.py", line 99, in <module>
    from .mtrand import *
ImportError: /home/gongming/pythonwork/cityeye/local/lib/python2.7/site-packages/numpy/random/mtrand.so: undefined symbol: PyFPE_jbuf
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 10716)
...
spawned uWSGI worker 20 (pid: 10737, cores: 1)
spawned uWSGI http 1 (pid: 10738)