Python uwsgi 在 pyenv/2.7.11 下使用 _io.so 失败:未定义符号:_PyCodecInfo_GetIncrementalEncoder
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34167557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
uwsgi fails under pyenv/2.7.11 with _io.so: undefined symbol: _PyCodecInfo_GetIncrementalEncoder
提问by jayshilling
when i start uwsgi 2.0.11.2 under pyenv 2.7.11 i get:
当我在 pyenv 2.7.11 下启动 uwsgi 2.0.11.2 时,我得到:
ImportError: /home/user/.pyenv/versions/2.7.11/envs/master2/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyCodecInfo_GetIncrementalEncoder
导入错误:/home/user/.pyenv/versions/2.7.11/envs/master2/lib/python2.7/lib-dynload/_io.so:未定义符号:_PyCodecInfo_GetIncrementalEncoder
also uwsgi prints Python version: 2.7.10 (default, May 30 2015, 13:57:08) [GCC 4.8.2]
uwsgi 还打印 Python 版本:2.7.10(默认,2015 年 5 月 30 日,13:57:08)[GCC 4.8.2]
not sure how to fix it
不知道如何解决
采纳答案by CristiFati
I had the same (or better: a similar) problem with uwsgiwhen upgrading Pythonfrom 2.7.3to 2.7.10:
有问题的:我有同样的(类似或更好)uwsgi升级时的Python从2.7.3至2.7.10:
- The module that I tried to import was socket(socket.py)
- Which in turn tried to import _socket(_socket.so) - and the unresolved symbol was
_PyInt_AsInt
- Which in turn tried to import _socket(_socket.so) - and the unresolved symbol was
- 我尝试导入的模块是socket( socket.py)
- 依次尝试导入_socket( _socket.so) - 并且未解析的符号是
_PyInt_AsInt
- 依次尝试导入_socket( _socket.so) - 并且未解析的符号是
The problem is a mismatch between some functions between Pythonminor minorreleases (which doesn't break any backward compatibility, BTW). Let me detail:
问题是Python次要版本之间的某些功能不匹配(这不会破坏任何向后兼容性,顺便说一句)。详细说一下:
Build time: when your uwsgiwas built, the build was against Python 2.7.10(as you specified). Pythoncould have been compiled/built:
- statically - most likely, the PYTHON LIBRARY(from now on, I am going to refer to it as PYTHONCOREas it's named by its creators) in this case: (libpython2.7.a) is in a static lib which is included in the pythonexecutable resulting a huge ~6MB executable
- dynamically - PYTHONCORE(libpython2.7.so) is a dynamic library which pythonexecutable (~10KB of bytes large, this time) uses at runtime
Run time: the above uwsgimust run in an Python 2.7.11environment
建造时间:当你的uwsgi建,构建反对的Python 2.7.10(如指定)。Python可以被编译/构建:
- 静态 - 最有可能的是,在这种情况下,PYTHON 库(从现在开始,我将把它称为PYTHONCORE,因为它是由它的创建者命名的)在这种情况下:(libpython2.7.a)位于包含在python可执行文件产生了一个巨大的 ~6MB 可执行文件
- 动态 - PYTHONCORE( libpython2.7.so) 是一个动态库,python可执行文件(这次约 10KB 字节大)在运行时使用
运行时:以上uwsgi必须在Python 2.7.11环境下运行
Regardless of how Pythonis compiled, the following thing happened: between 2.7.10and 2.7.11some internal functions were added/removed (in our case added) from both:
不管Python是如何编译的,都会发生以下事情:在2.7.10和2.7.11之间,一些内部函数被添加/删除(在我们的例子中添加):
- PYTHONCORE
- Dynamic (or extension) modules (written in C) - .sofiles located in ${PYTHON_LIB_DIR}/lib-dynload(e.g. /home/user/.pyenv/versions/2.7.11/envs/master2/lib/python2.7/lib-dynload); any dynamic module (.so) is a client for PYTHONCORE
- 蟒蛇
- 动态(或扩展)模块(用C编写) - .so文件位于${PYTHON_LIB_DIR}/lib-dynload(例如/home/user/.pyenv/versions/2.7.11/envs/master2/lib/python2.7 /lib-dynload); 任何动态模块(.so)都是PYTHONCORE的客户端
So, basically it's a version mismatch (encountered at runtime):
所以,基本上这是一个版本不匹配(在运行时遇到):
2.7.10(which uwsgiwas compiled against):
- PYTHONCORE- doesn't export
PyCodecInfo_GetIncrementalEncoder
- _io.so(obviously) doesn't use the exported func (so, no complains at importtime)
- PYTHONCORE- doesn't export
2.7.11(which uwsgiis run against):
- PYTHONCORE- still(as it was "embedded" in uwsgiat compile (build) time, so it's still 2.7.10) doesn't export
PyCodecInfo_GetIncrementalEncoder
- _io.so- uses/needs it
- PYTHONCORE- still(as it was "embedded" in uwsgiat compile (build) time, so it's still 2.7.10) doesn't export
2.7.10(其uwsgi是针对编译):
- PYTHONCORE- 不导出
PyCodecInfo_GetIncrementalEncoder
- _io.so(显然)不使用导出的 func(因此,在导入时没有抱怨)
- PYTHONCORE- 不导出
2.7.11(其uwsgi抵靠运行):
- PYTHONCORE-还是(因为它是在“嵌入式”uwsgi在编译(构建)的时间,所以它仍然是2.7.10)不出口
PyCodecInfo_GetIncrementalEncoder
- _io.so- 使用/需要它
- PYTHONCORE-还是(因为它是在“嵌入式”uwsgi在编译(构建)的时间,所以它仍然是2.7.10)不出口
resulting a situation where a Python 2.7.11dynamic module was used against Python 2.7.10runtime, which is unsupported.
导致在Python 2.7.10运行时使用Python 2.7.11动态模块的情况,这是不受支持的。
As a conclusion make sure that your uwsgibuildmachine is in sync (from PythonPoV) with the runmachine, or - in other words - build uwsgiwith the same Pythonversion you intend to run it with!
作为结论,请确保您的uwsgibuildmachine是同步的(从Python的POV)与runmachine,或者-换句话说-构建uwsgi具有相同的Python版本,你打算与运行它!
回答by jayshilling
CristiFati covered the why part. The exact how to for me was:
CristiFati 涵盖了原因部分。对我来说确切的方法是:
cd my_pyenv_virtualenv
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar xf uwsgi-latest.tar.gz
cd uwsgi-2.0.11.2
python uwsgiconfig.py --build
mv uwsgi /home/user/.pyenv/versions/2.7.11/envs/master2/bin/uwsgi
回答by duhaime
I had the same error on RHEL, and eventually discovered it was due to the tsch shell I was using. I solved the problem by switching to the bash shell:
我在 RHEL 上遇到了同样的错误,最终发现这是由于我使用的 tsch shell。我通过切换到 bash shell 解决了这个问题:
bash
which allowed my script to run fine.
这让我的脚本运行良好。