在Ubuntu 18.04上,使用pip安装uWSGI失败。

4
尝试从命令行安装uWSGI
pip install uwsgi

导致长堆栈跟踪的结果,以下是其结尾:

/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.a(parser.o):
 relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; 
recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
*** error linking uWSGI ***

    ----------------------------------------
Command "/home/user/venv/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ve0nx9k8/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-l_7f937a/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/venv/include/site/python3.6/uwsgi" failed with error code 1 in /tmp/pip-install-ve0nx9k8/uwsgi/

我正在使用Python 3.6。Python 2可以工作,Python 3.7也可以工作,但不幸的是我需要使用Python 3.6。虚拟环境中没有其他内容,这是一个相当新的Ubuntu重新安装。


我找到了这个链接,看起来在虚拟环境中没有解决方案。https://github.com/unbit/uwsgi/issues/1770 - ltd9938
@leech,您正在尝试安装哪个uWSGI版本? - maciek
2个回答

0

这个错误意味着链接器想要构建一个Position Independent Executable (PIE object),但是它无法这样做,因为库libpython3.6m.a没有支持这种链接的构建。

我在使用通过pyenv安装的Python时遇到了这个问题。

在这种情况下,修复问题的方法是使用特殊的编译器标志重新安装Python:

CONFIGURE_OPTS=--enable-shared pyenv install 3.7.7  # use your Python version

这在他们的维基中提到过,但对我来说,什么时候需要这样的标志还不清楚。


-2

我在使用系统 Python 进行构建时遇到了此错误。当我切换到 pyenv 并安装了定制的 Python 版本后,uWSGI 安装成功。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接