Repository: spyder-ide/spyder

Issue:
Launch Issues with 4.2.1 and macOS
## Problem Description
I just installed Spyder 4.1.5 through Anaconda in a new ARM MacBook Pro with Big Sur, I had some problems at the beginning with high latency problems, but  I updated QT to v5.12.5 and problems gone.

The point is that Spyder notify me that I could update to 4.2 so I did that, and Spyder never launch again, then I tested to update to v4.2.1 that perfectly launch, so I'm at the point that I have Spyder 4.2.1 and Qt 5.12.5 and everything works.

But, and here is where I need help, all times I launch Spyder I get an Issue Reporter that tells me: "Spyder has encountered an internal problem", you can se the paste of problem detail below:

```python-traceback
  File "/Users/vicentegt/anaconda3/lib/python3.8/site-packages/spyder/plugins/editor/widgets/status.py", line 113, in process_git_data
    branches, branch, files_modified = output
TypeError: cannot unpack non-iterable NoneType object
```

That happen every time when I launch Spyder, if I close that everything works, but it's a bit annoying and im worried that some complex task could go wrong. It also open in the script editor a script called "spyder" that I never created or opened:

```python-traceback
#!/bin/bash /Users/vicentegt/anaconda3/bin/pythonw

# -*- coding: utf-8 -*-
import re
import sys

from spyder.app.start import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
```

and when I run ti I get:

_Spyder is already running. If you want to open a new 
instance, please pass to it the --new-instance option_

### What steps reproduce the problem?

1. Take an Apple Silicon, ARM M1 MacBook Pro with macOS Big Sur
2. Install Anaconda
3. Update Spyder by conda forge channel to v4.2.1
4. Update Qt by conda forge channel to 5.12.5
5. Launch spyder

### What is the expected output? What do you see instead?

The expected output is to don't get and Issue Report window.


### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

  File "/Users/vicentegt/anaconda3/lib/python3.8/site-packages/spyder/plugins/editor/widgets/status.py", line 113, in process_git_data
    branches, branch, files_modified = output
TypeError: cannot unpack non-iterable NoneType object

```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 4.2.1
* Python version: 3.8.5
* Qt version: 5.12.5
* PyQt version: 5.12.3
* Operating System name/version: macOS Big Sur

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```

# Mandatory:
applaunchservices >=0.1.7       :  0.2.1 (OK)
atomicwrites >=1.2.0            :  1.4.0 (OK)
chardet >=2.0.0                 :  4.0.0 (OK)
cloudpickle >=0.5.0             :  1.6.0 (OK)
diff_match_patch >=20181111     :  20200713 (OK)
intervaltree >=3.0.2            :  3.1.0 (OK)
IPython >=7.6.0                 :  7.19.0 (OK)
jedi =0.17.2                    :  0.17.2 (OK)
jsonschema >=3.2.0              :  3.2.0 (OK)
keyring >=17.0.0                :  21.4.0 (OK)
nbconvert >=4.0                 :  6.0.7 (OK)
numpydoc >=0.6.0                :  1.1.0 (OK)
parso =0.7.0                    :  0.7.0 (OK)
pexpect >=4.4.0                 :  4.8.0 (OK)
pickleshare >=0.4               :  0.7.5 (OK)
psutil >=5.3                    :  5.7.2 (OK)
pygments >=2.0                  :  2.7.3 (OK)
pylint >=1.0                    :  2.6.0 (OK)
pyls >=0.36.2;<1.0.0            :  0.36.2 (OK)
pyls_black >=0.4.6              :  0.4.6 (OK)
pyls_spyder >=0.3.0             :  0.3.0 (OK)
qdarkstyle >=2.8                :  2.8.1 (OK)
qtawesome >=0.5.7               :  1.0.1 (OK)
qtconsole >=5.0.1               :  5.0.1 (OK)
qtpy >=1.5.0                    :  1.9.0 (OK)
rtree >=0.8.3                   :  0.9.4 (OK)
setuptools >=39.0.0             :  51.0.0.post20201207 (OK)
sphinx >=0.6.6                  :  3.4.0 (OK)
spyder_kernels >=1.10.1;<1.11.0 :  1.10.1 (OK)
textdistance >=4.2.0            :  4.2.0 (OK)
three_merge >=0.1.1             :  0.1.1 (OK)
watchdog >=0.10.3               :  0.10.4 (OK)
zmq >=17                        :  20.0.0 (OK)

# Optional:
cython >=0.21                   :  0.29.21 (OK)
matplotlib >=2.0.0              :  3.3.2 (OK)
numpy >=1.7                     :  1.19.2 (OK)
pandas >=1.1.1                  :  1.1.5 (OK)
scipy >=0.17.0                  :  1.5.2 (OK)
sympy >=0.7.3                   :  1.7.1 (OK)
```



Discussion:
Hey @vivito51, thanks for reporting. You said:

> so I'm at the point that I have Spyder 4.2.1 and Qt 5.12.5 and everything works.

That's the right combination to make Spyder work in Big Sur, so you need to stay with it.

> But, and here is where I need help, all times I launch Spyder I get an Issue Reporter that tells me: "Spyder has encountered an internal problem"

Question about this problem: do you have `git` installed in your system?

> That happen every time when I launch Spyder, if I close that everything works, but it's a bit annoying and im worried that some complex task could go wrong

It's safe to ignore it for now. We'll try to fix it in our next version (4.2.2), to be released in mid February.

> It also open in the script editor a script called "spyder" that I never created or opened

This seems another problem with Big Sur. It's the script used to open Spyder, so you don't need to run it or do anything with it. We'll also try to fix this problem for 4.2.2.
If you want to have a Spyder installation without these problems, please use our  [DMG installer](https://github.com/spyder-ide/spyder/releases/download/v4.2.1/Spyder.dmg) in the meantime.

By following the instructions we wrote [here](http://docs.spyder-ide.org/current/faq.html#using-existing-environment), you'll be able to connect our app to your current conda envs.
I'm having similar issues with Spyder 4.2.1 on Mojave.
If launched from the terminal or gui pointing to the conda install, it works fine but opens the spyder script as mentioned above.
If launched from the new dmg install, it crashes straight away (this didn't happen with the previous dmg version).
Thanks for your complete answer @ccordoba12 , related to that:
> Question about this problem: do you have `git` installed in your system?

I don't have git installed neither at my Mac or Anaconda.

> If you want to have a Spyder installation without these problems, please use our DMG installer in the meantime.

I just did that but I didn't know how to use my conda packages with Spyder if it's installed "out" of Anaconda or miniforge. So what u send me here: 
> By following the instructions we wrote here, you'll be able to connect our app to your current conda envs.

Seems to be the solution of my problems while I wait for some future updates. Thank you so much! That was just what I needed because Spyder "out" of conda work perfectly fine for me.

Thanks again, 
Vicente.


I'm having a similar issue after updated to Big Sur with both anaconda-spyder and spyder4.2.1 stand alone unable to launch. The icon will pop up at the dock, but nothing happens, and indicating program/python 3.7 not responding. Tried to uninstall and reinstall, but the commands for un/reinstall doesn't working either.... 
Any suggestions? @ccordoba12 
Please open Terminal and run there

    spyder --debug-info verbose --debug-output file

and upload the file called `spyder-debug.log`, which should be created in the directory where you ran that command.
I have to say that what @ccordoba12 suggested me work perfectly. I have a standalone Spyder install that picks my python env and pkgs from Anaconda. I had a bit of troubles with spyder-kernels but its solved just updating them.

Thanks again, that setup works while I wait Anaconda to update.
I am having the exact same issues as OP. Spyder works, but the startup messages and automatic opening of the spyder script (descibed in OP) is an annoyance. 

It looks like no one has uploaded the spyder-debug.log 

Here is mine:

[spyder-debug.log](https://github.com/spyder-ide/spyder/files/5755116/spyder-debug.log)





Same problem here. If there's any more data needed to debug, feel free to ping me!

Error:

```python
  File "/opt/anaconda3/envs/lambda-analyse-articles/lib/python3.8/site-packages/spyder/plugins/editor/widgets/status.py", line 113, in process_git_data
    branches, branch, files_modified = output
TypeError: cannot unpack non-iterable NoneType object
```

Also, I have git installed and am using it.
I'll write down here the configuration that works for me. Maybe it's useful for you @robbwh @BastianZim .

As anaconda isn't still ARM native I downloaded [mambaforge](https://github.com/conda-forge/miniforge/releases) (which is ARM compatible). Then I installed standalone spyder from [here](https://github.com/spyder-ide/spyder/releases/latest/download/Spyder.dmg). Once I have mambaforge and Spyder the way to link them is: Spyder > Preferences > Python Interpreter > Select the following python interpreter: /Users/your_user/mambaforge/bin/python3.9

After that you will have an issue when Spyder open, something about spyder-kernels is missing in your selected python eviroment. Solve that is really easy, just go to Applications Folder on your Mac, find Spyder.app then control+click and show package content, then go to: Contents/Resources/lib/python3.9/ there find "spyder_kernels" folder and copy it to your ~/ (home directory).

Once you have that folder there, just start spyder and it will find by default the kerners that you just set in your home directory. And everything should work perfectly. At least it work for me with MacBook Pro M1 with Big Sur 11.1.

Hope that helps you while we wait for future updates. Happy New Year!


> After that you will have an issue when Spyder open, something about spyder-kernels is missing in your selected python eviroment. Solve that is really easy, just go to Applications Folder on your Mac, find Spyder.app then control+click and show package content, then go to: Contents/Resources/lib/python3.9/ there find "spyder_kernels" folder and copy it to your ~/ (home directory).

Thanks for your help @vivito51. Although possible, this is not the right way to install `spyder-kernels`. What you need to do is running in your conda env this command:

    mamba install spyder-kernels=1.10.1
> Thanks for your help @vivito51. Although possible, this is not the right way to install `spyder-kernels`. What you need to do is running in your conda env this command:
> 
> ```
> mamba install spyder-kernels=1.10.1
> ```

Thanks @ccordoba12 I actually try to do that but I get the following error:

```
(base) vicentegt@arm64-apple-darwin20 ~ % mamba install spyder-kernels=1.10.1
Looking for: ['spyder-kernels=1.10.1']
conda-forge/osx-arm64    Using cache
conda-forge/noarch       Using cache
Encountered problems while solving.
Problem: nothing provides requested spyder-kernels 1.10.1**
```

If I run `mamba list` I can see the following spyder-kernel package: 
` spyder-kernels            0.2.6                      py_1    conda-forge`
But I think that this is an old versiond that don't actually work with Spyder 4.2.1.

That's why I ended up copy-pasting the kernels from original Spyder.app folder to home directory. Do you know how to solve that error?
Ok, then I guess you need to run

    mamba install -c conda-forge spyder-kernels=1.10.1

(I thought Mamba used conda-forge by default).
It still doesn't work @ccordoba12 : 

```
(base) vicentegt@arm64-apple-darwin20 ~ % mamba install -c conda-forge spyder-kernels=1.10.1
Looking for: ['spyder-kernels=1.10.1']
pkgs/main/osx-arm64      [====================] (00m:00s) Done
pkgs/r/osx-arm64         [====================] (00m:00s) 404 Failed
conda-forge/osx-arm64    [====================] (00m:00s) Done
pkgs/main/noarch         [====================] (00m:03s) Done
pkgs/r/noarch            [====================] (00m:03s) Done
conda-forge/noarch       [====================] (00m:05s) Done
Encountered problems while solving.
Problem: nothing provides requested spyder-kernels 1.10.1**
```
Ok, I understand what happens now: the problem is that spyder-kernels is not available for the new `arm64` architecture of M1 chips. I opened this pull request to see what we can do about it:

https://github.com/conda-forge/spyder-kernels-feedstock/pull/60
@ccordoba12 thank you! I see that they said we should wait about 1 week from now. At least we can manually take spyder-kernels from spyder.app/contents folder just copying it to home directory. It works for me by now even if it's not the correct way to install it. 

Thank you for all your help!

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -2806,6 +2806,7 @@ def open_external_file(self, fname):
         Open external files that can be handled either by the Editor or the
         variable explorer inside Spyder.
         """
+        # Check that file exists
         fname = encoding.to_unicode_from_fs(fname)
         if osp.exists(osp.join(CWD, fname)):
             fpath = osp.join(CWD, fname)
@@ -2814,6 +2815,11 @@ def open_external_file(self, fname):
         else:
             return
 
+        # Don't open script that starts Spyder at startup.
+        # Fixes issue spyder-ide/spyder#14483
+        if sys.platform == 'darwin' and 'bin/spyder' in fname:
+            return
+
         if osp.isfile(fpath):
             self.open_file(fpath, external=True)
         elif osp.isdir(fpath):


Test patch: