Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 Matplotlib找不到字体系列[u';无衬线';]_Python 2.7_Matplotlib_Fonts_Anaconda - Fatal编程技术网

Python 2.7 Matplotlib找不到字体系列[u';无衬线';]

Python 2.7 Matplotlib找不到字体系列[u';无衬线';],python-2.7,matplotlib,fonts,anaconda,Python 2.7,Matplotlib,Fonts,Anaconda,我使用anaconda(使用python 2.7.16)安装了matplotlib 2.2.3。在更高版本的matplotlib(>1.5.1)上,我总是会遇到缺少字体的问题 我知道网络上有很多解决方案,但都没有解决我的问题。我已经尝试了以下建议,但没有一个有用: sudo apt-get install msttcorefonts -qq sudo apt install font-manager rm ~/.cache/matplotlib -fr 为了避免这个问题,我不想再回到matpl

我使用anaconda(使用python 2.7.16)安装了matplotlib 2.2.3。在更高版本的matplotlib(>1.5.1)上,我总是会遇到缺少字体的问题

我知道网络上有很多解决方案,但都没有解决我的问题。我已经尝试了以下建议,但没有一个有用:

sudo apt-get install msttcorefonts -qq
sudo apt install font-manager
rm ~/.cache/matplotlib -fr
为了避免这个问题,我不想再回到matplotlib的旧版本。请帮忙。我的代码是

 from matplotlib import rcParams
 rcParams['font.family'] = 'sans-serif'
 rcParams['font.sans-serif'] = ['Tahoma']

 import matplotlib.pyplot as plt

 .......................

你的操作系统是什么?排除
rcParams['font.sans serif']=['Tahoma']
时是否也会发生错误?我想是吧?我猜错误来自于python 2.7似乎不理解的
'sans-serif'
字符串。是的,在注释掉
rcParams['font.sans-serif']=['Tahoma']
后仍然存在问题。我的主要操作系统是ubuntu 18.04。在2台台式机、1台笔记本电脑中遇到此问题。我在macbook上也遇到了同样的问题,我用anaconda安装了所有东西。我在matplotlib 1.5.3中没有发现任何问题,但是这个问题出现在任何高于这个的地方。我很沮丧。非常感谢。我尝试了多个序言,一些是在matplotlib官方页面上推荐的:
fontProperties={'family':'sans-serif','sans-serif':['Helvetica'],'weight':'normal','size':14}从matplotlib导入rc rc('font',**fontProperties)#对于Palatino和其他serif字体,使用:rc('font'**{'family':'serif','serif':['Palatino']})rc('text',usetex=True)
python 3.x也会出现这种情况吗?我没有尝试过,但我以前的代码与python 3.x不兼容。我现在真的不想切换到python 3。此外,我发现这是一个重大问题,无论如何都应该解决。您的操作系统是什么?当您排除
rcParams['font.sans serif']=['Tahoma'时是否也会发生错误
?我猜是的?我猜错误来自
“sans-serif”
字符串,python 2.7似乎不理解该字符串。是的,在注释掉
rcParams['font.sans-serif']=['Tahoma']后仍然存在问题
。我的主要操作系统是Ubuntu18.04。在两台台式机、一台笔记本电脑上出现了这个问题。我在macbook上也遇到了同样的问题,我用anaconda安装了所有东西。matplotlib 1.5.3中没有问题,但这个问题出现在任何更高版本中。我非常沮丧。非常感谢。我尝试了多个序言,一些推荐在matplotlib官方页面:
fontProperties={'family':'sans-serif','sans-serif':['Helvetica'],'weight':'normal','size':14}从matplotlib导入rc('font',**fontProperties)#对于Palatino和其他衬线字体,使用:rc('font',**{'family':'serif','serif':['Palatino']})rc('text',usetex=True)
python 3.x也会出现这种情况吗?我没有尝试过,但我以前的代码与python 3.x不兼容。我现在真的不想切换到python 3。此外,我发现这是一个主要问题,无论如何都应该解决。
 from matplotlib import rcParams
 rcParams['font.family'] = 'sans-serif'
 rcParams['font.sans-serif'] = ['Tahoma']

 import matplotlib.pyplot as plt

 .......................