我使用迁移助手将所有东西从Intel Mac迁移到M1 Mac。现在,当我尝试运行使用matplotlib
的Python程序Tiling_2023时,我得到以下错误:
> python Tiling_2023.py
Traceback (most recent call last):
File "/Users/Ryan/My Corner/Projects/Python/Tiling/Tiling_2023.py", line 5, in <module>
import numpy as np, itertools as it, bisect as b, copy, math, matplotlib.pyplot as plt, matplotlib.ticker as mticker, functools, os
File "/Users/Ryan/.pyenv/versions/3.10.0/lib/python3.10/site-packages/matplotlib/__init__.py", line 131, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/Users/Ryan/.pyenv/versions/3.10.0/lib/python3.10/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/Users/Ryan/.pyenv/versions/3.10.0/lib/python3.10/site-packages/matplotlib/colors.py", line 51, in <module>
from PIL import Image
File "/Users/Ryan/.local/lib/python3.10/site-packages/PIL/Image.py", line 103, in <module>
from . import _imaging as core
ImportError: dlopen(/Users/Ryan/.local/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 0x0002): tried: '/Users/Ryan/.local/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
字符串
我该如何解决此问题?我尝试pip卸载matplotlib并使用pip install --no-binary :all: matplotlib
再次安装它,就像另一个question上关于一个可能类似的问题所建议的那样,但没有工作。我使用的是Python 3.10.0和pyenv。
1条答案
按热度按时间wr98u20j1#
pip install --upgrade --force-reinstall matplotlib
通过强制pip重新安装matplotlib及其所有依赖项修复了该问题。