Octave Fontconfig 错误

21

我按照这里的指示使用Homebrew安装了Octave。

当我尝试生成一个图时,会收到以下消息:

Fontconfig error: Cannot load default config file
warning: could not match any font: *-normal-normal-10
warning: called from
    axes at line 66 column 10
    gca at line 58 column 9
    newplot at line 148 column 8
    surf at line 70 column 9
    sombrero at line 65 column 5

接下来,我会收到一长串类似以下的消息:

warning: ft_render: unable to load appropriate font
warning: could not match any font: *-normal-normal-10

通常情况下,这个情节只会出现一次,但如果我再次调用它,Octave 就会弹出以下消息并退出。

panic: Segmentation fault: 11 -- stopping myself...
attempting to save variables to 'octave-workspace'...
warning: unable to open 'octave-workspace' for writing...
warning: called from
    __gnuplot_drawnow__>gnuplot_trim_term at line 368 column 10
    __gnuplot_drawnow__>gnuplot_set_term at line 119 column 20
    __gnuplot_drawnow__ at line 84 column 16
Segmentation fault: 11

在讨论类似错误时,我经常看到对/etc/fonts/fonts.conf的引用。 我的/ etc目录中没有包含字体子目录。 这可能是问题的根源,但我不知道如何解决它。 当我运行brew install fontconfig时,我收到Warning: fontconfig-2.11.1_1 already installed的提示。 当我运行sudo find / -name fonts.conf时,我会得到/opt/X11/lib/X11/fontconfig/fonts.conf

brew doctor产生了以下警告,这些警告可能与问题有关,但我不知道如何解决(除非卸载Anaconda):

Warning: Anaconda is known to frequently break Homebrew builds, including Vim 
and MacVim, due to bundling many duplicates of system and Homebrew-available
tools.

If you encounter a build failure please temporarily remove Anaconda
from your $PATH and attempt the build again prior to reporting the
failure to us. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
    /Users/greg/anaconda/bin/curl-config
    /Users/greg/anaconda/bin/freetype-config
    /Users/greg/anaconda/bin/libdynd-config
    /Users/greg/anaconda/bin/libpng-config
    /Users/greg/anaconda/bin/libpng16-config
    /Users/greg/anaconda/bin/python-config
    /Users/greg/anaconda/bin/python2-config
    /Users/greg/anaconda/bin/python2.7-config
    /Users/greg/anaconda/bin/xml2-config
    /Users/greg/anaconda/bin/xslt-config

我正在使用OS X 10.11.3(El Capitan)。

2个回答

41

尝试

brew uninstall fontconfig

brew install fontconfig --universal

如果您没有或不想使用XQuartz,可以使用Qt。

brew uninstall gnuplot

brew install gnuplot --with-qt

2
希望我能告诉你在找到这个答案之前我尝试了多少事情...非常感谢你。 - David John Smith
收到一个关于过时警告的信息 - brew install gnuplot --with-qt。这个命令可以使用:brew install gnuplot --with-qt5。 - bsandhu
这适用于OSX 10.11.6(El Capitan)和Octave 4.0.3。 - Chris Jaynes

39

实际上,这不是Octave的问题,而是由于其复杂的设置和其他工具(特别是fontconfig)的错误配置。

为了正常工作,您需要手动设置fontconfig的路径,以便它不会在不合适的目录中寻找字体文件(例如,在Linux安装中,/etc/fonts可行,但是OS X XQuartz则不同)。

您应该运行命令export FONTCONFIG_PATH=/opt/X11/lib/X11/fontconfig来正确设置fontconfig。还可以将export FONTCONFIG_PATH=/opt/X11/lib/X11/fontconfig一行添加到您的~/.bash_profile中,并重新启动终端,这样您就不需要再运行此命令。


1
有没有学习这些技术的有效方法?也许有什么书可以阅读,以了解诸如bash配置文件和类Unix文件系统等工作原理? - gsganden
很遗憾,我无法推荐具体的东西,这需要经验和尝试。我花了大约一个小时通过谷歌错误信息并将其他人复制的问题与我的配置进行比较来解决此问题。 - OleGG
3
这帮了我大忙 - 谢谢。注意:为了使它正常工作,你需要安装http://www.xquartz.org/。 - jameswilsterman
非常感谢您的回答。帮了大忙! - Jim Clouse
@OleGG 为此不得不赞扬你。现在我晚回家只有1个小时,而不是3个小时了。谢谢! - blue-sky

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接