报错如下:

      The headers or library files could not be found for zlib,
      a required dependency when compiling Pillow from source.

      Please see the install instructions at:
         https://pillow.readthedocs.io/en/latest/installation.html

      Traceback (most recent call last):
        File "/tmp/pip-install-hc7ffxdd/pillow_691ead8a6a1c48d0b8d84a80470f3787/setup.py", line 1020, in <module>
          zip_safe=not (debug_build() or PLATFORM_MINGW),
        File "/home/pypy/lib/pypy3.8/site-packages/setuptools/__init__.py", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/home/pypy/lib/pypy3.8/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/home/pypy/lib/pypy3.8/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/home/pypy/lib/pypy3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/home/pypy/lib/pypy3.8/site-packages/setuptools/command/install.py", line 61, in run
          return orig.install.run(self)
        File "/home/pypy/lib/pypy3.8/distutils/command/install.py", line 552, in run
          self.run_command('build')
        File "/home/pypy/lib/pypy3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/home/pypy/lib/pypy3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/home/pypy/lib/pypy3.8/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/home/pypy/lib/pypy3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/home/pypy/lib/pypy3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/home/pypy/lib/pypy3.8/site-packages/setuptools/command/build_ext.py", line 79, in run
          _build_ext.run(self)
        File "/home/pypy/lib/pypy3.8/distutils/command/build_ext.py", line 343, in run
          self.build_extensions()
        File "/tmp/pip-install-hc7ffxdd/pillow_691ead8a6a1c48d0b8d84a80470f3787/setup.py", line 788, in build_extensions
          raise RequiredDependencyException(f)
      RequiredDependencyException: zlib

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-hc7ffxdd/pillow_691ead8a6a1c48d0b8d84a80470f3787/setup.py", line 1033, in <module>
          raise RequiredDependencyException(msg)
      RequiredDependencyException:

      The headers or library files could not be found for zlib,
      a required dependency when compiling Pillow from source.

      Please see the install instructions at:
         https://pillow.readthedocs.io/en/latest/installation.html

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> Pillow

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

解决办法:

sudo apt-get install libjpeg-dev zlib1g-dev 

重新安装:

pip3 install Pillow