我的脚本需要导入numpy
、sklearn
、和{pip
为所有用户重新安装numpy
、matplotlib
、scipy
和{
当我使用命令运行我完成的脚本时
python DistMatPlot.py Random10A.matrix Random10A.pdf
脚本运行得很好,写入了所有预期的输出文件。在
然而,我总是看到:
"/Library/Python/2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')"
在更新numpy、matplotlib等之前,我从未见过其他matplotlib脚本。2秒的延迟只是有点烦人。在
我使用pyinstaller编译了一个冻结的二进制文件,在编译过程中,我收到了一些与上面类似的消息。 生成的冻结二进制运行失败,命令为:
./DistMatPlot Random10A.matrix Random10A.pdf
制作如下:
/var/folders/8x/7_zp_33h8xj6td0059b72p9h0000gp/T/_MEIhIysTV/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. Traceback (most recent call last): File "", line 13, in File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "matplotlib/pyplot.py", line 114, in File "matplotlib/backends/init.py", line 32, in pylab_setup File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "matplotlib/backends/backend_macosx.py", line 24, in File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 546, in load_module module = imp.load_module(fullname, fp, filename, ext_tuple) RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ DistMatPlot returned -1
我看过类似的问题,并尝试了他们提出的解决办法,但都没有结果。在
(1)为什么matplotlib每次运行时都需要重建字体缓存?在
(2)当脚本本身成功时,为什么冻结的二进制文件失败?在运行pyinstaller时,除了-F我还需要其他选项吗?在
冻结的二进制文件的问题是“RuntimeError:Python不是作为框架安装的。”
一些帖子讨论了这个问题,并建议在“导入”之前添加这两行matplotlib.pyplot作为plt:
导入matplotlib
matplotlib.使用('TkAgg')
这不起作用,但这一点小小的修改确实奏效了: 导入matplotlib
matplotlib.使用('Agg')
我怀疑'Agg'可能特定于OSX或OSX10.11附带的python版本
相关问题 更多 >
编程相关推荐