2

I've had a MacBook given to me from work for over a year now and recently I got a new mac and every time I launch a python script the python launcher icon appears in the mac dock. However, in the old MacBook, this behaviour doesn't exist. Both running the exact same script.

I'm not sure if there was a setting I changed or something else on the old one to disable this behaviour.

I've read this question: How to get rid of Python Launcher icon every time a script runs? But I'm mostly confused why my old MacBook doesn't encounter this.

They are both running the exact same version of macOS: 10.15.6 (19G73)

If its important I installed Python on the new one by the installer(provided by python.org) and I used homebrew on the old one.

2
  • 1
    It obvious that whatever the file extension is, it has a different default app on each Mac to handle it. See what it is on the older Mac and then on the newer Mac set it the same as on the older Mac. You should Google: mac os how to change default application Jul 30, 2020 at 2:19
  • as @user3439894 said, see which application is called by Python now as opposed to the older machine. Now it probably calls the Python Launcher instead of just Python.
    – Natsfan
    Jul 30, 2020 at 15:52

2 Answers 2

1

Well, it sure seems the difference is caused by different methods of installing Python. If your systems are identical then its caused by Python itself. You could try installing python via homebrew on your new machine and see if the behavior changes. You should run python in a virtual environment. If you do that you can have multiple versions of python3 on your machine.

How are you running Python? If you run it from the command line you may not have this happen. Are you trying to stop this behavior or are you just curious why it happens? If you are trying to stop it then use the file you link to in your question.

2
  • I'm running Python normally through pycharm, but it also happends when I run it just through terminal as well. Apologies I should of been more explict in my question. I am trying to figure out how to stop this. But the question I linked doesnt solve the issue. I'm really confused on what I did on the old mac to not have this. I tried uninstalling python then reinstalling it with brew however it still happends.
    – Lucas
    Jul 30, 2020 at 13:43
  • Yea i read the article you linked. You're right, it doesn't tell you how to stop it but it does tell you how to keep from getting multiple python launcher icons.
    – Natsfan
    Jul 30, 2020 at 15:39
0

To prevent the Python icon: Python icon in the dock from appearing in the dock, add this to your script:

import matplotlib
matplotlib.use("Agg")

In my case, the appearance of the icon was apparently caused by matplotlib, and the fix I described is from this answer.

1
  • That is a very specific case - and we have no idea what the OP is using matplotlib. The most important bit of that answr is the first sentance "On OS X the Dock will display an icon for Python whenever you do something that interacts with the GUI. "
    – mmmmmm
    Nov 10 at 11:55

Not the answer you're looking for? Browse other questions tagged .