Repository: spyder-ide/spyder

Issue:
macOS standalone installer failing due to black 22.10.0
```
creating build/bdist.macosx-10.15-x86_64/python3.9-standalone/app/lib-dynload
[26](https://github.com/spyder-ide/spyder/actions/runs/3205861357/jobs/5238913081#step:8:27)
creating build/bdist.macosx-10.15-x86_64/python3.9-standalone/app/Frameworks
[27](https://github.com/spyder-ide/spyder/actions/runs/3205861357/jobs/5238913081#step:8:28)
error: [Errno 2] No such file or directory: '/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/black-22.10.0.dist-info/top_level.txt'
```
Can't find a usable init.tcl
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

import tkinter as tk

window = tk.TK()
window.titel('Hello World')

window.mainloop()

This is the script which I want to learn, but if I try to run it there appears a TclError which is:

/usr/local/Cellar/tcl-tk/8.6.12_1/lib/tcl8.6 /Applications/Spyder.app/Contents/lib/tcl8.6 /Applications/Spyder.app/lib/tcl8.6 /Applications/Spyder.app/Contents/library /Applications/Spyder.app/library /Applications/Spyder.app/tcl8.6.12/library /Applications/tcl8.6.12/library

This error appears when tkinter is imported and a window should be opened. 

The software is macOS Ventura 13.0.1 and Python 3.9.14





## Versions

* Spyder version: 5.4.0 510c6249c (standalone)
* Python version: 3.9.14 64-bit
* Qt version: 5.15.2
* PyQt5 version: 5.15.7
* Operating System: Darwin 22.1.0

### Dependencies

```
# Mandatory:
atomicwrites >=1.2.0                 :  1.4.1 (OK)
chardet >=2.0.0                      :  5.0.0 (OK)
cloudpickle >=0.5.0                  :  2.2.0 (OK)
cookiecutter >=1.6.0                 :  2.1.1 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree >=3.0.2                 :  3.1.0 (OK)
IPython >=7.31.1;<8.0.0              :  7.34.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.17.0 (OK)
keyring >=17.0.0                     :  23.9.3 (OK)
nbconvert >=4.0                      :  7.2.3 (OK)
numpydoc >=0.6.0                     :  1.5.0 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.3 (OK)
pygments >=2.0                       :  2.13.0 (OK)
pylint >=2.5.0;<3.0                  :  2.15.5 (OK)
pylint_venv >=2.1.1                  :  None (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.6.0;<1.7.0                 :  1.6.0 (OK)
pylsp_black >=1.2.0                  :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.2.2                    :  0.2.2 (OK)
qtawesome >=1.2.1                    :  1.2.1 (OK)
qtconsole >=5.4.0;<5.5.0             :  5.4.0 (OK)
qtpy >=2.1.0                         :  2.2.1 (OK)
rtree >=0.9.7                        :  1.0.1 (OK)
setuptools >=49.6.0                  :  65.5.1 (OK)
sphinx >=0.6.6                       :  5.1.1 (OK)
spyder_kernels >=2.4.0;<2.5.0        :  2.4.0 (OK)
textdistance >=4.2.0                 :  4.5.0 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog >=0.10.3                    :  2.1.9 (OK)
zmq >=22.1.0                         :  24.0.1 (OK)

# Optional:
cython >=0.21                        :  0.29.32 (OK)
matplotlib >=3.0.0                   :  3.6.2 (OK)
numpy >=1.7                          :  1.22.4 (OK)
pandas >=1.1.1                       :  1.5.1 (OK)
scipy >=0.17.0                       :  1.9.3 (OK)
sympy >=0.7.3                        :  1.11.1 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)
```



Discussion:

Hey @Ludwig19258, thanks for reporting. Please post a screenshot of what you're seeing in Spyder to better understand your problem.
Hey @ccordoba12 thanks for the answer.

<img width="1440" alt="Bildschirm­foto 2022-12-21 um 18 02 36" src="https://user-images.githubusercontent.com/121129855/208962796-dc607338-94a5-47e6-9676-7b1a0dc4b81e.png">

I am quite new to GitHub, so excuse me if I do some mistakes. 
Don't worry, that's fine. Your initial report was quite good, I just wanted to see what you're seeing to better understand your problem.

A couple of other questions for you:

1. Did you set an external interpreter in `Preferences > Python interpreter`?
2. Do you have Homebrew installed in your computer?
So I tried to set an external interpreter but my computer crashed every time. 

I don't have Homebrew installed. For what do I need it?
> So I tried to set an external interpreter but my computer crashed every time.

Ok, no problem. Then please set the default option in

    Preferences > Python interpreter

![imagen](https://user-images.githubusercontent.com/365293/209164544-de70e12d-f3e7-4348-bcfb-3fda542977bd.png)

and try again.

> I don't have Homebrew installed. For what do I need it?

Don't  worry, I thought that could be interfering with Spyder somehow.
Closing due to lack of response.
I have the same issue, but the suggested solution (setting Python Interpeter to default) didn't change anything. 
I do, however, have homebrew installed. Spyder was installed on macos (Ventura) as a .dmg rather than through anaconda-navigator. 
<img width="637" alt="Screenshot 2023-12-08 at 3 17 29 PM" src="https://github.com/spyder-ide/spyder/assets/16409070/3b05c40e-e20e-4cfa-9c64-3d3aaf5b432d">

I have the exact same problem too but with macOS Sonoma with the standalone spyder app. I also tried the suggestion of setting the Python interpreter to default but has not changed anything. Exact same error message posted by @softmatter-ca above.

Editing to add that i've also tried setting the backend to Tkinter instead of Graphical but it hasn't helped. @ccordoba12 Could you help please or shall I post this as a new issue?
Hey @mgad02, thanks for letting us know about it. Let's reopen this issue to see what we can do about it.

@mrclary, could you test this with our 5.5.0 Mac app? Thanks!
Okay, I've found the issue is two-fold.
* First, the OP is a direct result of running our x86_64 standalone application on arm64. @Ludwig19258 @softmatter-ca @mgad02, perhaps you could confirm that you are running on Apple silicon.
* However, there is an additional underlying issue where the tcl-tk flags were not correctly set on the Python build used for the build environment of our standalone application (see pyenv/pyenv#2794). Strangely this does not seem to affect our standalone application running on Intel (x86_64).

I can create new build for both x86_64 and arm64 of Spyder's v5.5.0 standalone application. @ccordoba12, I'll create a `5.5.0_1` branch and tag to build from and upload the artifacts to the `5.5.0` release page. We can then merge the change into the `5.x` branch.

Resolving patch:
diff --git a/installers/macOS/setup.py b/installers/macOS/setup.py
--- a/installers/macOS/setup.py
+++ b/installers/macOS/setup.py
@@ -16,6 +16,7 @@
 from logging import getLogger, StreamHandler, Formatter
 from pathlib import Path
 from setuptools import setup
+from platform import machine
 
 from spyder import get_versions
 
@@ -98,6 +99,18 @@ def make_app_bundle(dist_dir, make_lite=False):
     return
 
 
+def disk_image_name(make_lite=False):
+    """
+    Return disk image name
+    """
+    dmg_name = f'Spyder-{SPYVER}_{machine()}'
+    if make_lite:
+        dmg_name += '-Lite'
+    dmg_name += '.dmg'
+
+    return dmg_name
+
+
 def make_disk_image(dist_dir, make_lite=False):
     """
     Make macOS disk image containing Spyder.app application bundle.
@@ -117,12 +130,9 @@ def make_disk_image(dist_dir, make_lite=False):
     from dmgbuild.core import DMGError
 
     volume_name = '{}-{} Py-{}.{}.{}'.format(APP_BASE_NAME, SPYVER, *PYVER)
-    dmg_name = 'Spyder'
     if make_lite:
         volume_name += ' Lite'
-        dmg_name += '-Lite'
-    dmg_name += '.dmg'
-    dmgfile = (dist_dir / dmg_name).as_posix()
+    dmgfile = (dist_dir / disk_image_name(make_lite)).as_posix()
 
     settings_file = (THISDIR / 'dmg_settings.py').as_posix()
     settings = {
@@ -162,9 +172,17 @@ def make_disk_image(dist_dir, make_lite=False):
     parser.add_argument('-b', '--bdist-base', dest='build_dir',
                         default='build',
                         help='Build directory; passed to py2app')
+    parser.add_argument(
+        '-m', '--dmg-name', dest='dmg_name', action='store_true',
+        help='Return the DMG name: Spyder-{VER}_{ARCH}-{LITE}.dmg'
+    )
 
     args, rem = parser.parse_known_args()
 
+    if args.dmg_name:
+        print(disk_image_name(args.make_lite))
+        sys.exit()
+
     # Groom sys.argv for py2app
     sys.argv = sys.argv[:1] + ['py2app'] + rem
 


Test patch: