简体   繁体   English

如何阻止 Python Rocket 出现在 Python 3.8 中?

[英]How I can stop Python Rocket From Appearing in Python 3.8?

Here is my code:这是我的代码:

import matplotlib.pyplot
from graph_tool import *
from graph_tool import draw


if __name__ == '__main__':


    g = Graph()
    

    v1 = g.add_vertex()
    v2 = g.add_vertex()

    e = g.add_edge(v1, v2)    

    draw.graph_draw(g, vertex_text=g.vertex_index, output="two-nodes.pdf")

I am using Python 3.8 and I run this code on Mac Os Catalina 10.15.6.我正在使用 Python 3.8 并在 Mac Os Catalina 10.15.6 上运行此代码。 My problem is after the line "from graph_tool import draw" is executed, Python rocket appears in Dock.我的问题是在执行“from graph_tool import draw”行后,Dock 中出现了 Python 火箭。 I think it is very annoying and I don't want to see it.我认为这很烦人,我不想看到它。 I edited the file:我编辑了文件:

/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/Info.plist

I added "LSUIElement 1" at the end of the file, just before " ".我在文件末尾添加了“LSUIElement 1”,就在“”之前。 However, this did not resolve the problem.然而,这并没有解决问题。 If anyone knows how I can prevent that annoying rocket from appearing, it will be highly appreciated.如果有人知道我可以如何防止那个烦人的火箭出现,将不胜感激。

With my respects以我的敬意

Instead of代替

import matplotlib.pyplot as plt

try尝试

import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

It's important that the first two lines come before the line import matplotlib.pyplot as plt .重要的是前两行出现import matplotlib.pyplot as plt之前。 This seems to be an issue with python on OS X, especially with matplotlib.这似乎是 OS X 上 python 的问题,尤其是 matplotlib。 By Default, on OS X, matplotlib uses the macosx backend which is a interactive Backend(Which causes the rocket ship).默认情况下,在 OS X 上,matplotlib 使用macosx后端,它是一个交互式后端(这会导致火箭飞船)。 This Code changes the default backend to the Agg backend, which is non-interactive.此代码将默认后端更改为非交互式的Agg后端。

You can find more details on https://leancrew.com/all-this/2014/01/stopping-the-python-rocketship-icon/您可以在https://leancrew.com/all-this/2014/01/stopping-the-python-rocketship-icon/上找到更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM