ERROR: Failed compiling the bootloader. Please compile manually and rerun setup.py

在Ubuntu中使用pip安装PyInstaller时遇到错误,提示缺少zlib开发包。解决方法是通过sudo apt-get install安装zlib1g和zlib1g.dev。如果仍然失败,可能需要先安装ruby,再安装zlib1g-dev。
摘要由CSDN通过智能技术生成

1. 问题现象

在使用 pip 安装 pyinstaller 时,有如下错误

$ sudo pip3 install  pyinstaller==4.5.1   -i https://pypi.douban.com/simple/

Collecting pyinstaller==4.5.1
  Downloading https://pypi.doubanio.com/packages/a9/d9/9fdfb0ac2354d059e466d562689dbe53a23c4062019da2057f0eaed635e0/pyinstaller-4.5.1.tar.gz (2.7MB)
    100% |████████████████████████████████| 2.7MB 525kB/s 
Requirement already satisfied: altgraph in /usr/local/lib/python3.6/dist-packages (from pyinstaller==4.5.1)
Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in /usr/local/lib/python3.6/dist-packages (from pyinstaller==4.5.1)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from pyinstaller==4.5.1)
Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.6/dist-packages (from pyinstaller==4.5.1)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata->pyinstaller==4.5.1)
Requirement already satisfied: typing-extensions>=3.6.4; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from importlib-metadata->pyinstaller==4.5.1)
Installing collected packages: pyinstaller
  Running setup.py install for pyinstaller ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2xm0_yha/pyinstaller/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-ur3vlz3l-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_bootloader
    No precompiled bootloader found. Trying to compile it for you ...
    Setting top to                           : /tmp/pip-build-2xm0_yha/pyinstaller/bootloader
    Setting out to                           : /tmp/pip-build-2xm0_yha/pyinstaller/bootloader/build
    Python Version                           : 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
    Checking for 'gcc' (C compiler)          : /usr/bin/gcc
    Checking size of pointer                 : 8
    Platform                                 : Linux-64bit-intel detected based on compiler
    Checking for compiler flags -m64         : yes
    Checking for linker flags -m64           : yes
    Checking for library dl                  : yes
    Checking for library pthread             : yes
    Checking for library m                   : yes
    Checking for library z                   : no
    The zlib development package is either missing or the shared library cannot be linked against. For security (and marginally better filesize), you should install the zlib-dev or zlib-devel packages with your system package manager and try again. If you cannot do this, for example distributions such as OpenWRT use sstrip on libraries making linking impossible, then either use the --static-zlib option or set the PYI_STATIC_ZLIB=1 environment variable. If you are installing directly with pip, then use the environment variable.
    (complete log in /tmp/pip-build-2xm0_yha/pyinstaller/bootloader/build/config.log)
    ERROR: Failed compiling the bootloader. Please compile manually and rerun setup.py
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2xm0_yha/pyinstaller/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-ur3vlz3l-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-2xm0_yha/pyinstaller/

2. 解决方法

ubuntu 软件源里 zlibzlib-devel 叫做 zlib1g zlib1g.dev

sudo apt-get install zlib1g
sudo apt-get install zlib1g.dev

直接输入上述命令后如果还是不能安装。这就要求我们先装 ruby

sudo apt-get install ruby

然后再装 zlib1g-dev 就可以了

sudo apt-get install zlib1g-dev
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wohu007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值