WIN10专业版python 3.8.9 32位 pip 安装pillow时总是报这个错误。上网查找了不少内容,总结了三种可能有用的办法,我自己是通过第二种解决的。
尝试1.将pip升级到最新 python -m pip install --upgrade pip,然后重试,一般没用。极少数情况下有效。
尝试2.检查python版本,在这个网站上查询合适的pillow版本,适当降级:Installation - Pillow (PIL Fork) 10.1.0.dev0 documentation
主要看这个,尽量选9点几的版本,因为我感觉9点几的应该是whl包
10点几版本都是自动下载的 .tar.gz包一个有50M大。
我按最低要求换成9.2.0包,下载的是whl文件,只有2.8M大(这个也可以自行到PyPI网上搜索下载尽量下载whl格式文件,然后在文件夹中shift加鼠标右键进入cmd环境,pip install 加 完整文件名带后缀来离线安装)
我记得曾经也有不少其他的tar.gz格式的包不能安装,最后我网上下载他的whl格式的包直接离线安装成功的,对于别的包这也算是一个通用尝试办法吧。
尝试3,如果需要安装10版本的pillow包,遇到无法安装报错Building wheel for Pillow error的情况,百度文库上有一篇文章,我觉得可行度很高。文章链接building wheel for pillow error - 百度文库
原文主要内容:
The error message "Building wheel for Pillow" usually appears during the installation process when pip is trying to build the necessary wheel file for the module. A wheel file is a package format for Python that contains all the necessary files and metadata to install a module. It's a pre-built distribution that makes installation faster and more efficient.
The problemwith the "Building wheel for Pillow error" is that pip cannot find a pre-built wheel for your system in the Python Package Index (PyPI), the official repository for Python packages. As a result.it has to build the wheel from the source code, which requires the correct build tools and development headers for your system.
How to Fix the "Building wheel for Pillow error"?
To fix the "Building wheel for Pillow error," you need to make sure that you have the correct build tools and development headers installed on your system. Here are the steps:
Step l: Install the Build Tools
If you are using Windows, you need to install Microsoft Visual C++ Build Tools. Download the latest version from the official Microsoft website and install it on your machine. Make sure you select the 'Python development workload" option during installation.
If you are using macos, you need to install the Xcode command-line tools. Open the Terminal app and type in the following command:
xcode-select --install
Follow the pronpts to install the coumand-line tools.
If you are using Linux, you need to install the development headers for Python and some basic build tools. The exact packages may vary depending on your distribution, but you can try the following coumands:
- Debian/Ubuntu:sudo apt-get install python3-deypython3-pil python3-setuptools build-essential-Red Hat/Centos/Fedora:sudo yum install python3-devel python3-pillowpython3-setuptools gcc
Step 2: Try Installing Pillow Again
After installing the necessary build tools, try installing Pillow again by running the pip coumand:
pip install pillow
If everything goes well, pip should find a pre-built wheel file for your system and install Pillow
without any errors.
Conclusion
The"Building wheel for Pillow error" can be frustrating, but it's usually caused by a lack of build tools and development headers on your system By following the steps outlined in this article, you can fix the error and install Pillow with ease. Remember to always keep your build tools up to date to avoid similar errors in the future.
那么可见,windows需要去微软官网下载安装最新版Microsoft Visual C++ Build Tools,安装时要勾选'Python development workload"选项。然后重新pip 安装pillow 。Linux和苹果系统我就先不翻译了。
最后文章作者的总结也很有意思:
“Building wheel for Pillow error”可能会令人沮丧,但它通常是由缺乏构建工具和系统上的开发头文件引起的,通过遵循本文中概述的步骤,您可以轻松地修复错误并安装Pillow。请记住,始终保持您的构建工具是最新的,以避免将来出现类似的错误。