We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Bug]: Use of pythonw on macos conda/mamba environments breaks app
### PsychoPy Version

2024.1.3

### What OS are your PsychoPy running on?

macOS Silicon

### Bug Description

When attempting to run the psychopy GUI app following an install in a fresh conda environment:

```
conda create -n pyschopy python=3.10
pip install pyschopy
psychopy
```
Psychopy fails to start.


### Expected Behaviour

Psychopy should not need to call pythonw for versions of python >= 3.9, and the if statement in `psychopyApp.py` should be modified to reflect that probably (or python < 3.9 support dropped entirely for newer versions of the package).

### Steps to Reproduce

After installing as above the following error is returned:

```
Traceback (most recent call last):
  File "/Users/MYUSERNAME/mambaforge/envs/intermod/bin/psychopy", line 8, in <module>
    sys.exit(main())
  File "/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/site-packages/psychopy/app/psychopyApp.py", line 90, in main
    stdout, stderr = core.shellCall(cmd,
  File "/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/site-packages/psychopy/core.py", line 153, in shellCall
    proc = subprocess.Popen(cmdObjects, stdin=subprocess.PIPE,
  File "/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/MYUSERNAME/mambaforge/envs/intermod/bin/python3.10w'
```

This error happens because, according to `psychopyApp.py`, we need to call `pythonw` when running GUI scripts on MacOS in an Anaconda-based environment. However this is an outdated method as of Python 3.9, and [from that version onwards you can now directly call the python binary regardless](https://docs.python.org/3/using/mac.html#running-scripts-with-a-gui). 

In a fresh Python 3.10 installation via conda/mamba the pythonw binary does not exist in the binaries folder for the environment. I have for the moment fixed this by simply symlinking the base python binary to `python3.10w` which psychopy expects, which then allows the app to start.


### Additional context

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `psychopy/app/psychopyApp.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # Part of the PsychoPy library
5 # Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2024 Open Science Tools Ltd.
6 # Distributed under the terms of the GNU General Public License (GPL).
7 
8 import sys
9 
10 # fix macOS locale-bug on startup: sets locale to LC_ALL (must be defined!)
11 import psychopy.locale_setup  # noqa
12 
13 
14 # NB the PsychoPyApp classes moved to _psychopyApp.py as of version 1.78.00
15 # to allow for better upgrading possibilities from the mac app bundle. this
16 # file now used solely as a launcher for the app, not as the app itself.
17 
18 
19 def start_app():
20     from psychopy.app import startApp, quitApp
21     from psychopy.preferences import prefs
22 
23     showSplash = prefs.app['showSplash']
24     if '--no-splash' in sys.argv:
25         showSplash = False
26         del sys.argv[sys.argv.index('--no-splash')]
27     _ = startApp(showSplash=showSplash)  # main loop
28     quitApp()
29 
30 
31 def main():
32     if '-x' in sys.argv:
33         # run a .py script from the command line using StandAlone python
34         targetScript = sys.argv[sys.argv.index('-x') + 1]
35         from psychopy import core
36         import os
37         core.shellCall([sys.executable, os.path.abspath(targetScript)])
38         sys.exit()
39     if '-v' in sys.argv or '--version' in sys.argv:
40         from psychopy import __version__
41         msg = ('PsychoPy3, version %s (c)Jonathan Peirce 2018, GNU GPL license'
42                % __version__)
43         print(msg)
44         sys.exit()
45     if '-h' in sys.argv or '--help' in sys.argv:
46         print("""Starts the PsychoPy3 application.
47 
48 Usage:  python PsychoPy.py [options] [file]
49 
50 Without options or files provided this starts PsychoPy using prefs to
51 decide on the view(s) to open.  If optional [file] is provided action
52 depends on the type of the [file]:
53 
54  Python script 'file.py' -- opens coder
55 
56  Experiment design 'file.psyexp' -- opens builder
57 
58 Options:
59     -c, --coder, coder       opens coder view only
60     -b, --builder, builder   opens builder view only
61     -x script.py             execute script.py using StandAlone python
62 
63     -v, --version    prints version and exits
64     -h, --help       prints this help and exit
65 
66     --firstrun       launches configuration wizard
67     --no-splash      suppresses splash screen
68 
69 """)
70         sys.exit()
71 
72     if (sys.platform == 'darwin' and
73             ('| packaged by conda-forge |' in sys.version or
74              '|Anaconda' in sys.version)):
75 
76         # On macOS with Anaconda, GUI applications need to be run using
77         # `pythonw`. Since we have no way to determine whether this is currently
78         # the case, we run this script again -- ensuring we're definitely using
79         # pythonw.
80         import os
81         env = os.environ
82         PYTHONW = env.get('PYTHONW', 'False')
83 
84         if PYTHONW != 'True':
85             from psychopy import core
86             cmd = [sys.executable + 'w', __file__]
87             if '--no-splash' in sys.argv:
88                 cmd.append('--no-splash')
89 
90             stdout, stderr = core.shellCall(cmd,
91                                             env=dict(env, PYTHONW='True'),
92                                             stderr=True)
93             print(stdout, file=sys.stdout)
94             print(stderr, file=sys.stderr)
95             sys.exit()
96         else:
97             start_app()
98     else:
99         start_app()
100 
101 
102 if __name__ == '__main__':
103     main()
104
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/psychopy/app/psychopyApp.py b/psychopy/app/psychopyApp.py
--- a/psychopy/app/psychopyApp.py
+++ b/psychopy/app/psychopyApp.py
@@ -69,9 +69,8 @@
 """)
         sys.exit()
 
-    if (sys.platform == 'darwin' and
-            ('| packaged by conda-forge |' in sys.version or
-             '|Anaconda' in sys.version)):
+    if (('| packaged by conda-forge |' in sys.version or '|Anaconda' in sys.version)
+        and sys.platform == 'darwin' and sys.version_info >= (3,9)):
 
         # On macOS with Anaconda, GUI applications need to be run using
         # `pythonw`. Since we have no way to determine whether this is currently

{"golden_diff": "diff --git a/psychopy/app/psychopyApp.py b/psychopy/app/psychopyApp.py\n--- a/psychopy/app/psychopyApp.py\n+++ b/psychopy/app/psychopyApp.py\n@@ -69,9 +69,8 @@\n \"\"\")\n         sys.exit()\n \n-    if (sys.platform == 'darwin' and\n-            ('| packaged by conda-forge |' in sys.version or\n-             '|Anaconda' in sys.version)):\n+    if (('| packaged by conda-forge |' in sys.version or '|Anaconda' in sys.version)\n+        and sys.platform == 'darwin' and sys.version_info >= (3,9)):\n \n         # On macOS with Anaconda, GUI applications need to be run using\n         # `pythonw`. Since we have no way to determine whether this is currently\n", "issue": "[Bug]: Use of pythonw on macos conda/mamba environments breaks app\n### PsychoPy Version\r\n\r\n2024.1.3\r\n\r\n### What OS are your PsychoPy running on?\r\n\r\nmacOS Silicon\r\n\r\n### Bug Description\r\n\r\nWhen attempting to run the psychopy GUI app following an install in a fresh conda environment:\r\n\r\n```\r\nconda create -n pyschopy python=3.10\r\npip install pyschopy\r\npsychopy\r\n```\r\nPsychopy fails to start.\r\n\r\n\r\n### Expected Behaviour\r\n\r\nPsychopy should not need to call pythonw for versions of python >= 3.9, and the if statement in `psychopyApp.py` should be modified to reflect that probably (or python < 3.9 support dropped entirely for newer versions of the package).\r\n\r\n### Steps to Reproduce\r\n\r\nAfter installing as above the following error is returned:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/MYUSERNAME/mambaforge/envs/intermod/bin/psychopy\", line 8, in <module>\r\n    sys.exit(main())\r\n  File \"/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/site-packages/psychopy/app/psychopyApp.py\", line 90, in main\r\n    stdout, stderr = core.shellCall(cmd,\r\n  File \"/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/site-packages/psychopy/core.py\", line 153, in shellCall\r\n    proc = subprocess.Popen(cmdObjects, stdin=subprocess.PIPE,\r\n  File \"/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/subprocess.py\", line 971, in __init__\r\n    self._execute_child(args, executable, preexec_fn, close_fds,\r\n  File \"/Users/MYUSERNAME/mambaforge/envs/intermod/lib/python3.10/subprocess.py\", line 1863, in _execute_child\r\n    raise child_exception_type(errno_num, err_msg, err_filename)\r\nFileNotFoundError: [Errno 2] No such file or directory: '/Users/MYUSERNAME/mambaforge/envs/intermod/bin/python3.10w'\r\n```\r\n\r\nThis error happens because, according to `psychopyApp.py`, we need to call `pythonw` when running GUI scripts on MacOS in an Anaconda-based environment. However this is an outdated method as of Python 3.9, and [from that version onwards you can now directly call the python binary regardless](https://docs.python.org/3/using/mac.html#running-scripts-with-a-gui). \r\n\r\nIn a fresh Python 3.10 installation via conda/mamba the pythonw binary does not exist in the binaries folder for the environment. I have for the moment fixed this by simply symlinking the base python binary to `python3.10w` which psychopy expects, which then allows the app to start.\r\n\r\n\r\n### Additional context\r\n\r\n_No response_\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Part of the PsychoPy library\n# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2024 Open Science Tools Ltd.\n# Distributed under the terms of the GNU General Public License (GPL).\n\nimport sys\n\n# fix macOS locale-bug on startup: sets locale to LC_ALL (must be defined!)\nimport psychopy.locale_setup  # noqa\n\n\n# NB the PsychoPyApp classes moved to _psychopyApp.py as of version 1.78.00\n# to allow for better upgrading possibilities from the mac app bundle. this\n# file now used solely as a launcher for the app, not as the app itself.\n\n\ndef start_app():\n    from psychopy.app import startApp, quitApp\n    from psychopy.preferences import prefs\n\n    showSplash = prefs.app['showSplash']\n    if '--no-splash' in sys.argv:\n        showSplash = False\n        del sys.argv[sys.argv.index('--no-splash')]\n    _ = startApp(showSplash=showSplash)  # main loop\n    quitApp()\n\n\ndef main():\n    if '-x' in sys.argv:\n        # run a .py script from the command line using StandAlone python\n        targetScript = sys.argv[sys.argv.index('-x') + 1]\n        from psychopy import core\n        import os\n        core.shellCall([sys.executable, os.path.abspath(targetScript)])\n        sys.exit()\n    if '-v' in sys.argv or '--version' in sys.argv:\n        from psychopy import __version__\n        msg = ('PsychoPy3, version %s (c)Jonathan Peirce 2018, GNU GPL license'\n               % __version__)\n        print(msg)\n        sys.exit()\n    if '-h' in sys.argv or '--help' in sys.argv:\n        print(\"\"\"Starts the PsychoPy3 application.\n\nUsage:  python PsychoPy.py [options] [file]\n\nWithout options or files provided this starts PsychoPy using prefs to\ndecide on the view(s) to open.  If optional [file] is provided action\ndepends on the type of the [file]:\n\n Python script 'file.py' -- opens coder\n\n Experiment design 'file.psyexp' -- opens builder\n\nOptions:\n    -c, --coder, coder       opens coder view only\n    -b, --builder, builder   opens builder view only\n    -x script.py             execute script.py using StandAlone python\n\n    -v, --version    prints version and exits\n    -h, --help       prints this help and exit\n\n    --firstrun       launches configuration wizard\n    --no-splash      suppresses splash screen\n\n\"\"\")\n        sys.exit()\n\n    if (sys.platform == 'darwin' and\n            ('| packaged by conda-forge |' in sys.version or\n             '|Anaconda' in sys.version)):\n\n        # On macOS with Anaconda, GUI applications need to be run using\n        # `pythonw`. Since we have no way to determine whether this is currently\n        # the case, we run this script again -- ensuring we're definitely using\n        # pythonw.\n        import os\n        env = os.environ\n        PYTHONW = env.get('PYTHONW', 'False')\n\n        if PYTHONW != 'True':\n            from psychopy import core\n            cmd = [sys.executable + 'w', __file__]\n            if '--no-splash' in sys.argv:\n                cmd.append('--no-splash')\n\n            stdout, stderr = core.shellCall(cmd,\n                                            env=dict(env, PYTHONW='True'),\n                                            stderr=True)\n            print(stdout, file=sys.stdout)\n            print(stderr, file=sys.stderr)\n            sys.exit()\n        else:\n            start_app()\n    else:\n        start_app()\n\n\nif __name__ == '__main__':\n    main()\n", "path": "psychopy/app/psychopyApp.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Part of the PsychoPy library\n# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2024 Open Science Tools Ltd.\n# Distributed under the terms of the GNU General Public License (GPL).\n\nimport sys\n\n# fix macOS locale-bug on startup: sets locale to LC_ALL (must be defined!)\nimport psychopy.locale_setup  # noqa\n\n\n# NB the PsychoPyApp classes moved to _psychopyApp.py as of version 1.78.00\n# to allow for better upgrading possibilities from the mac app bundle. this\n# file now used solely as a launcher for the app, not as the app itself.\n\n\ndef start_app():\n    from psychopy.app import startApp, quitApp\n    from psychopy.preferences import prefs\n\n    showSplash = prefs.app['showSplash']\n    if '--no-splash' in sys.argv:\n        showSplash = False\n        del sys.argv[sys.argv.index('--no-splash')]\n    _ = startApp(showSplash=showSplash)  # main loop\n    quitApp()\n\n\ndef main():\n    if '-x' in sys.argv:\n        # run a .py script from the command line using StandAlone python\n        targetScript = sys.argv[sys.argv.index('-x') + 1]\n        from psychopy import core\n        import os\n        core.shellCall([sys.executable, os.path.abspath(targetScript)])\n        sys.exit()\n    if '-v' in sys.argv or '--version' in sys.argv:\n        from psychopy import __version__\n        msg = ('PsychoPy3, version %s (c)Jonathan Peirce 2018, GNU GPL license'\n               % __version__)\n        print(msg)\n        sys.exit()\n    if '-h' in sys.argv or '--help' in sys.argv:\n        print(\"\"\"Starts the PsychoPy3 application.\n\nUsage:  python PsychoPy.py [options] [file]\n\nWithout options or files provided this starts PsychoPy using prefs to\ndecide on the view(s) to open.  If optional [file] is provided action\ndepends on the type of the [file]:\n\n Python script 'file.py' -- opens coder\n\n Experiment design 'file.psyexp' -- opens builder\n\nOptions:\n    -c, --coder, coder       opens coder view only\n    -b, --builder, builder   opens builder view only\n    -x script.py             execute script.py using StandAlone python\n\n    -v, --version    prints version and exits\n    -h, --help       prints this help and exit\n\n    --firstrun       launches configuration wizard\n    --no-splash      suppresses splash screen\n\n\"\"\")\n        sys.exit()\n\n    if (('| packaged by conda-forge |' in sys.version or '|Anaconda' in sys.version)\n        and sys.platform == 'darwin' and sys.version_info >= (3,9)):\n\n        # On macOS with Anaconda, GUI applications need to be run using\n        # `pythonw`. Since we have no way to determine whether this is currently\n        # the case, we run this script again -- ensuring we're definitely using\n        # pythonw.\n        import os\n        env = os.environ\n        PYTHONW = env.get('PYTHONW', 'False')\n\n        if PYTHONW != 'True':\n            from psychopy import core\n            cmd = [sys.executable + 'w', __file__]\n            if '--no-splash' in sys.argv:\n                cmd.append('--no-splash')\n\n            stdout, stderr = core.shellCall(cmd,\n                                            env=dict(env, PYTHONW='True'),\n                                            stderr=True)\n            print(stdout, file=sys.stdout)\n            print(stderr, file=sys.stderr)\n            sys.exit()\n        else:\n            start_app()\n    else:\n        start_app()\n\n\nif __name__ == '__main__':\n    main()\n", "path": "psychopy/app/psychopyApp.py"}]}