$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
尝试用cat /etc/debian_version命令,竟然可以显示出来Debian的版本。
$ cat /etc/debian_version
bookworm/sid
习惯性的用了apt install 命令安装,
sudo apt install spyder
安装完成后,spyder运行失败。开始还以为最新的Ubuntu与spyder不兼容,运行不了spyder。后来,看了自己以前写的文章。想起来以前是用pip install安装的。
重新在miniconda下,用pip安装:
pip install spyder
安装pyqt那个包时,等了30多分钟,快要结束时候,下载连接time out了...从头开始重新下...
中止安装,换成国内源,很快就完成了spyder的下载安装。
pip install spyder -i https://mirrors.aliyun.com/pypi/simple/
重启终端后,就可以运行spyder了,但还是会出现跟Debian下类似的错误。
在软件和更新中,修改附加驱动为Nvidia的专有驱动。重启系统后,再运行spyder,只剩下一个错误:
fromIccProfile: failed minimal tag size sanity
用代码查看了一下matplotlib支持的字体:
from matplotlib import font_manager
fontnamelist = font_manager.get_font_names()
print(fontnamelist)
没有出其他的中文支持:
['Gayathri', 'KacstFarsi', 'Mandali', 'Lohit Tamil', 'Lohit Odia', 'Norasi', 'Khmer OS System', 'Liberation Serif', 'MathJax_Caligraphic', 'Lohit Malayalam', 'Ramabhadra', 'Lohit Devanagari', 'MathJax_Size1', 'Lohit Telugu', 'LakkiReddy', 'padmaa-Bold.1.1', 'Samyak Gujarati', 'Suruma', 'Gubbi', 'Ubuntu Condensed', 'cmex10', 'RaviPrakash', 'Padauk Book', 'TenaliRamakrishna', 'URW Bookman', 'KacstQurn', 'DejaVu Serif', 'URW Gothic', 'KacstTitle', 'Phetsarath OT', 'elusiveicons', 'KacstOne', 'KacstPen', 'Standard Symbols PS', 'MathJax_Script', 'Pagul', 'C059', 'Rekha', 'Mitra ', 'cmsy10', 'Uroob', 'Tibetan Machine Uni', 'MathJax_SansSerif', 'DejaVu Serif Display', 'msam10', 'Ubuntu Mono', 'Lohit Gurmukhi', 'STIXNonUnicode', 'Potti Sreeramulu', 'Padauk', 'Samanata', 'Samyak Malayalam', 'ori1Uni', 'D050000L', 'Jamrul', 'Kinnari', 'Yrsa', 'Liberation Mono', 'Samyak Tamil', 'FreeSerif', 'Sarai', 'Peddana', 'Nimbus Roman', 'Kalimati', 'Likhan', 'KacstDigital', 'FreeSans', 'Nimbus Mono PS', 'wasy10', 'Vemana2000', 'NATS', 'Meera', 'MathJax_WinChrome', 'Navilu', 'Nimbus Sans', 'DejaVu Sans Mono', 'Chilanka', 'Nimbus Sans Narrow', 'KacstNaskh', 'AR PL UKai CN', 'AR PL UMing CN', 'Suravaram', 'cmtt10', 'Lohit Assamese', 'KacstScreen', 'STIXSizeThreeSym', 'Lohit Bengali', 'Ponnala', 'padmaa', 'Samyak Devanagari', 'Khmer OS', 'Kalapi', 'Nakula', 'Gurajada', 'Ramaraja', 'Lohit Tamil Classical', 'Syamala Ramana', 'Noto Sans Mono', 'Dhurjati', 'FontAwesome', 'Noto Serif CJK JP', 'Waree', 'NTR', 'Lohit Kannada', 'KacstPoster', 'STIXSizeTwoSym', 'Tlwg Typewriter', 'Rasa', 'MathJax_Fraktur', 'Droid Sans Fallback', 'Dyuthi', 'Saab', 'STIXGeneral', 'DejaVu Sans Display', 'Suranna', 'MathJax_Vector', 'esint10', 'Abyssinica SIL', 'Sawasdee', 'MathJax_WinIE6', 'cmmi10', 'Keraleeyam', 'Tlwg Typo', 'Sree Krushnadevaraya', 'MathJax_Size3', 'Gargi', 'Mukti', 'Mallanna', 'MathJax_Size2', 'Umpush', 'Z003', 'Ani', 'Laksaman', 'MathJax_Vector-Bold', 'cmr10', 'Chandas', 'Timmana', 'MathJax_Main', 'rsfs10', 'Sahadeva', 'Ubuntu', 'RaghuMalayalamSans', 'Rachana', 'Karumbi', 'Purisa', 'Liberation Sans Narrow', 'MathJax_AMS', 'cmss10', 'KacstTitleL', 'OpenSymbol', 'STIXSizeFiveSym', 'MathJax_Size4', 'MathJax_Math', 'KacstDecorative', 'eufm10', 'Loma', 'mry_KacstQurn', 'Gidugu', 'Tlwg Mono', 'KacstLetter', 'LKLUG', 'Manjari', 'Noto Sans CJK JP', 'Garuda', 'stmary10', 'FreeMono', 'DejaVu Sans', 'STIXSizeOneSym', 'STIXSizeFourSym', 'KacstArt', 'P052', 'MathJax_Typewriter', 'Pothana2000', 'dsrom10', 'AnjaliOldLipi', 'msbm10', 'Tlwg Typist', 'aakar', 'KacstOffice', 'Lohit Gujarati', 'cmb10', 'Noto Mono', 'KacstBook', 'Liberation Sans']
最后还是用了上次的'Noto Sans CJK JP'字体,显示出中文。
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = "Noto Sans CJK JP"
fig, ax = plt.subplots(figsize=(16/2,9/2), facecolor="#0c0c0c")
ax.axis("off")
fig.text(0.5,0.5, "测试中文", ha = "center", va="center", size=50, fontweight='extra bold',color="white")
plt.show()
【linux】解决matplotlib中文显示乱码-CSDN博客
【python】Debian安装miniconda、spyder、tushare-CSDN博客
pip国内镜像源-Python安装第三方库(一篇足以、都是干货,内含快捷方法) - 知乎
Matplotlib绘图如何添加任意字体 - 知乎