无法导入pylab?

时间:2010-12-18 20:03:22

标签: python macos matplotlib

我已经使用python 2.6在Snow Leopard上安装了numpy / scipy / matplotlib。导入pylab似乎不起作用。在调用'import pylab'时,我得到以下内容:

File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pylab.py", line 216, in <module>
    from matplotlib import mpl  # pulls in most modules
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/mpl.py", line 2, in <module>
    from matplotlib import axis
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py", line 10, in <module>
    import matplotlib.font_manager as font_manager
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 1339, in <module>
    _rebuild()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 1326, in _rebuild
    fontManager = FontManager()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 1004, in __init__
    self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 343, in findSystemFonts
    for f in get_fontconfig_fonts(fontext):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 301, in get_fontconfig_fonts
    output = pipe.communicate()[0]
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 683, in communicate
    stdout = self.stdout.read()

是什么给出的? pylab期待我没有的东西吗?它似乎无法阅读某些东西,但我真的不明白那是什么......

2 个答案:

答案 0 :(得分:5)

等一下。问题是fc-list第一次运行需要很长时间,所以它看起来像挂了;但是如果你等待2-3分钟就会完成,然后再运行得更快。

我在命令行以root身份运行fc-list,这可能会初始化某种缓存;不确定是否有必要,但它有效!

答案 1 :(得分:0)

$(document).ready(function() {

    var table = $('#example').DataTable( {
        dom:"tip",
        data:dataset.data,
        select:"multi",
        "columns": [
            { "data": "name", "title":"Namee" },
            { "data": "position", "title":"Position" },
            { "data": "office" , "title":"Office"},
            { "data": "extn" , "title":"Phone"},
            { "data": "start_date", "title":"Start" },
            { "data": "salary" , "title":"Salary"} 

        ],

        pagingType:"full",
        "infoCallback": function( settings, start, end, max, total, pre ) {
            var api = this.api();
            var pageInfo = api.page.info();
            var str = 'Page '+ (pageInfo.page+1) +' of '+ pageInfo.pages;
                if($('.paginate_info').length > 0){
                    $('.paginate_info').html(str);
                }
                else {
                    $(".paginate_button.previous").after("<span class='paginate_info'>"+str+"</span>");
                }
                 return"";
            },
           language": {
               "paginate": {  "first": "<<",last:">>",next:">",previous:"<"}}
        } );

     } );

如果你的python环境中成功安装了pylab。不会引起任何错误。