I'm having trouble getting matplotlib to work on pycharm on my M1 Mac. I am running the following code and getting the following error message. The goal is to open a miniseed file and plot the seismic data in it.
Code:
from obspy import read
import matplotlib.pyplot as plt
# Open MiniSEED file
st = read('/Users/petertsirushkin/Downloads/OO.HYS14..HDH.2020.092.00.00.00.000-2020.093.00.00.00.000.miniseed')
trace = st[0]
times = trace.times()
amplitudes = trace.data
# Plot the waveform
plt.plot(times, amplitudes)
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title('Seismic Waveform')
plt.show()
Error Message
ImportError: dlopen(/Users/petertsirushkin/PycharmProjects/pythonProject1/venv/lib/python3.11/site-packages/matplotlib/_c_internal_utils.cpython-311-darwin.so, 0x0002): tried: '/Users/petertsirushkin/PycharmProjects/pythonProject1/venv/lib/python3.11/site-packages/matplotlib/_c_internal_utils.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/petertsirushkin/PycharmProjects/pythonProject1/venv/lib/python3.11/site-packages/matplotlib/_c_internal_utils.cpython-311-darwin.so' (no such file), '/Users/petertsirushkin/PycharmProjects/pythonProject1/venv/lib/python3.11/site-packages/matplotlib/_c_internal_utils.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
I've tried installing an ARM64 version of matplotlib but I'm not sure if it's organized correctly in my mac's file structure and if pycharm is looking at it. When I do pip show matplotlib
in the command line I get the following information:
Name: matplotlib
Version: 3.7.1
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: matplotlib-users@python.org
License: PSF
Location: /Users/petertsirushkin/anaconda3/lib/python3.11/site-packages
Requires: contourpy, cycler, fonttools, kiwisolver, numpy, packaging, pillow, pyparsing, python-dateutil
Required-by: seaborn
And it seems like I have matplotlib 3.7.2 as the version that Python Interpreter sees in my pycharm project:
As for the software versions I am running: OSX Ventura 13.1; pycharm community edition 2022.2.5 build #PC-222.4554.11, built on March 15 2023 Runtime version: 17.0.6+7-b469.82 x82_64 VM: OpenJdk 64-Bit Server VM by JetBrains s.r.o