Python PIL/dylib 的问题以及与 macOS 的兼容性

Problem with Python PIL/dylib and compatibility with macOS

编辑:请查看我在下面写的评论

我是 运行ning macOS High Sierra 10.13.6 我想我已经下载了一个与我的 OS。电脑也预装了python2。 我已经安装了 ffmpeg 并将它存储在文档中,在一些帮助下,我将它放在路径中所以当我输入终端时:

>>> echo $PATH

输出是: Users/imac/Documents/ffmpeg:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin

当我 运行 一个应该工作的简单程序时我的终端输出(从 manim 教程中复制粘贴):

Traceback (most recent call last):
...(omitted)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/Image.py", line 132, in <module>
    from . import _imaging as core
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so, 
2): Symbol not found: ____chkstk_darwin
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/.dylibs/libtiff.5.dylib 
(which was built for Mac OS X 11.0)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/.dylibs/libtiff.5.dylib```

问题已解决:)

所以我遵循的步骤是:

  1. >>> pip3 uninstall Pillow
  2. >>> brew install libjpeg libtiff little-cms2 openjpeg webp
  3. >>> python3 -m pip install --upgrade pip
  4. >>> python3 -m pip install --upgrade Pillow --no-binary :all:

可以在此处找到推理和更多详细信息: https://pillow.readthedocs.io/en/latest/installation.html#building-on-macos

注:来自链接的第二个答案post ,我借用了第一个卸载命令。