目录
问题描述
Ubuntu16.04安装uwsgi时出现的错误。
(py36) root@ecs-7dec:/usr/local/web/django/oldMan# pip3 install uwsgi -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting uwsgi
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/24/fd/93851e4a076719199868d4c918cc93a52742e68370188c1c570a6e42a54f/uwsgi-2.0.20.tar.gz (804 kB)
Collecting some-package
Using cached some_package-0.1-py3-none-any.whl
Building wheels for collected packages: uwsgi
Building wheel for uwsgi (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /root/anaconda3/envs/py36/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b1z3zd63/uwsgi_7dd4eaa5c088463caa5814adbdff140a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b1z3zd63/uwsgi_7dd4eaa5c088463caa5814adbdff140a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-bxv37xjh
cwd: /tmp/pip-install-b1z3zd63/uwsgi_7dd4eaa5c088463caa5814adbdff140a/
原因
官方文档上说
To build uWSGI you need Python and a C compiler (gcc and clang are supported).
系统已经安装了Python 3.6, 可能gcc的版本不对, 但是上面错误说是LTO的版本不对。
This error basically means that you’ve got some binary build results (mostly object files) which are incompatible with other binary build results, but you’re trying to link them together.
ubuntu16.04的版本太高了。
解决方法
把GCC的版本改成需要的版本,安装4.8试试。
1.查看GCC,G++的版本的版本
gcc -v
g++ -v
2.重新安装低版本
sudo apt-get install gcc-4.8
3.查看当前版本
ls /usr/bin/gcc*
4.设置4.8为优先使用版本
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
5.重新安装uwsgi
pip install uwsgi
6.解决
(py36) root@ecs-7dec:/usr/local/web/django/oldMan# pip install uwsgi
Collecting uwsgi
Using cached uwsgi-2.0.20.tar.gz (804 kB)
Building wheels for collected packages: uwsgi
Building wheel for uwsgi (setup.py) ... done
Created wheel for uwsgi: filename=uWSGI-2.0.20-cp36-cp36m-linux_x86_64.whl size=1929621 sha256=1db4d9f8ea468f7e129699356c85a00b9625338bc25d26cfad7c7d7bc0b3dee7
Stored in directory: /root/.cache/pip/wheels/4a/60/83/bd5b22ba1a9298cc00c9f6400101b3757d958e10b1b38348f8
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.20
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv