当关注 quickstart UWSGI guide 时并尝试启动服务器,出现以下错误:
ImportError: dlopen(/Users/xxxxxxxx/anaconda3/lib/python3.7/lib-dynload/_struct.cpython-37m-darwin.so, 2): Symbol not found: _PyByteArray_Type
Referenced from: /Users/xxxxxxxx/anaconda3/lib/python3.7/lib-dynload/_struct.cpython-37m-darwin.so
Expected in: flat namespace
我尝试过的一些事情:
- 重新安装 UWSGI -
pip install --upgrade --force-reinstall --no-binary :all: --no-cache-dir uWSGI==2.0.17
- 重新安装 anaconda
线索:
- 应用程序将使用 werkzeug 开发服务器正常运行,没有错误。
- 在
~/anaconda3/bin/python
解释器中运行from struct import pack, unpack
不会导致错误 - '~/anaconda3/bin/python3' 和 '/Users/xxxxxxxx/anaconda3/bin/uwsgi' 都包含符号 (nm
/Users/xxxxxxxx/anaconda3/bin/uwsgi | grep _PyByteArray_Type
)
我该如何解决这个问题?如果这是一个新问题,我应该在哪里报告? Conda编译Python的方式有问题吗? UWSGI?
系统:
- 操作系统:OSX 10.15.2
- conda :4.7.12
- UWSGI:2.0.18
- 架构:x86_64
完整堆栈跟踪:
*** Starting uWSGI 2.0.18 (64bit) on [Wed Dec 18 19:46:58 2019] ***
compiled with version: 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4) on 17 December 2019 08:16:44
os: Darwin-19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64
nodename: base2010-6.local
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /private/tmp/mvp
detected binary path: /Users/xxxxxxxx/anaconda3/bin/uwsgi
your processes number limit is 2784
your memory page size is 4096 bytes
detected max file descriptor number: 256
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 3.7.1 (default, Dec 14 2018, 13:28:58) [Clang 4.0.1 (tags/RELEASE_401/final)]
Python main interpreter initialized at 0x7fcbd6c04a60
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 416560 bytes (406 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
Traceback (most recent call last):
File "myflaskapp.py", line 1, in <module>
from flask import Flask
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/site-packages/flask/__init__.py", line 14, in <module>
from jinja2 import escape
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
from jinja2 import nodes
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
from jinja2.utils import Markup
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/site-packages/jinja2/utils.py", line 16, in <module>
from jinja2._compat import text_type, string_types, implements_iterator, \
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/site-packages/jinja2/_compat.py", line 31, in <module>
import pickle
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/pickle.py", line 33, in <module>
from struct import pack, unpack
File "/Users/xxxxxxxx/anaconda3/lib/python3.7/struct.py", line 13, in <module>
from _struct import *
ImportError: dlopen(/Users/xxxxxxxx/anaconda3/lib/python3.7/lib-dynload/_struct.cpython-37m-darwin.so, 2): Symbol not found: _PyByteArray_Type
Referenced from: /Users/xxxxxxxx/anaconda3/lib/python3.7/lib-dynload/_struct.cpython-37m-darwin.so
Expected in: flat namespace
in /Users/xxxxxxxx/anaconda3/lib/python3.7/lib-dynload/_struct.cpython-37m-darwin.so
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: 9746)
spawned uWSGI worker 1 (pid: 9747, cores: 2)
spawned uWSGI worker 2 (pid: 9748, cores: 2)
spawned uWSGI worker 3 (pid: 9749, cores: 2)
spawned uWSGI worker 4 (pid: 9750, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
最佳答案
我有同样的问题并完全解决了 remove Anaconda python并通过自制软件安装 python (brew install python)。
关于python-3.x - 运行 UWSGI 时在 SO 中找不到符号 _PyByteArray_Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59403521/