If you install Spyder through Anaconda (or miniconda), its launcher in the Start Menu will behave correctly. However, if you pin it to the taskbar, it won't behave properly. Opening Spyder through that icon on the taskbar will open Spyder, but a new (duplicate) icon on the taskbar will appear. The expected behavior would instead be that the pinned icon represents the application window, and no duplicate icon appears.
To fix this bug, I have followed the instructions as per this comment on this GitHub Issue.
- Create a new text file in your preferred location, and call it
spyder-taskbar.py
with the following contents:wherefrom win32com.shell import shellcon from win32com.propsys import propsys, pscon import pythoncom shortcut_path = r"<anaconda-start-menu-folder>\Spyder.lnk" store = propsys.SHGetPropertyStoreFromParsingName(shortcut_path, None, shellcon.GPS_READWRITE, propsys.IID_IPropertyStore) store.SetValue(pscon.PKEY_AppUserModel_ID, propsys.PROPVARIANTType(u'spyder.Spyder', pythoncom.VT_LPWSTR)) store.Commit()
<anaconda-start-menu-folder>
is the location of Anaconda's folder in the Start Menu (to find it, open the Start Menu, navigate to the anaconda folder, right click on any item inside it and click "Open file location", then read the location bar—you can highlight it with Ctrl+L). - If your Anaconda installation is local (as in "user specific"), then open the Anaconda prompt from the Start Menu. If your installation is system-wide, then open the Anaconda prompt with administrator privileges.
- In the prompt, run
PS C:\> python path\to\spyder-taskbar.py
- Restart all instances of
explorer.exe
(the easiest way is to just restart your computer). - Observe that the Spyder icon in the Anaconda's Start Menu folder is marked as "New".
- Pin this new launcher to the taskbar.
Now the new taskbar icon should behave exactly as expected: new windows with Spyder will be captured by the pinned taskbar icon.
I am not responsible for any damage resulting from the steps above.
Kudos to @philipstarkey for fiddling with this and finding a solution.