Repository: spyder-ide/spyder

Issue:
TypeError when trying to detect the conda channel from which Spyder was installed
## Description

### What steps will reproduce the problem?

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

Issue reporter box came up as soon as I started up Spyder. Problem doesn't actually seem to cause any problems, though?

### Traceback
```python-traceback
Traceback (most recent call last):
  File "/Users/cclark/Soft/miniconda3/envs/main/lib/python3.11/site-packages/spyder/workers/updates.py", line 116, in start
    channel, channel_url = get_spyder_conda_channel()
    ^^^^^^^^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable NoneType object
```

## Versions

* Spyder version: 5.5.0  (conda)
* Python version: 3.11.6 64-bit
* Qt version: 5.15.11
* PyQt5 version: 5.15.10
* Operating System: macOS-13.6.1-arm64-i386-64bit

### Dependencies

```
# Mandatory:
applaunchservices >=0.3.0        :  0.3.0 (OK)
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  5.2.0 (OK)
cloudpickle >=0.5.0              :  3.0.0 (OK)
cookiecutter >=1.6.0             :  2.5.0 (OK)
diff_match_patch >=20181111      :  20230430 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.19.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.1 (OK)
jellyfish >=0.7                  :  1.0.3 (OK)
jsonschema >=3.2.0               :  4.20.0 (OK)
keyring >=17.0.0                 :  24.3.0 (OK)
nbconvert >=4.0                  :  7.14.0 (OK)
numpydoc >=0.6.0                 :  1.6.0 (OK)
parso >=0.7.0,<0.9.0             :  0.8.3 (OK)
pexpect >=4.4.0                  :  4.9.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  5.9.7 (OK)
pygments >=2.0                   :  2.17.2 (OK)
pylint >=2.5.0,<3.1              :  3.0.3 (OK)
pylint_venv >=3.0.2              :  3.0.3 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.9.0,<1.10.0            :  1.9.0 (OK)
pylsp_black >=1.2.0,<3.0.0       :  2.0.0 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.2 (OK)
qtawesome >=1.2.1                :  1.3.0 (OK)
qtconsole >=5.5.0,<5.6.0         :  5.5.1 (OK)
qtpy >=2.1.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.1.0 (OK)
setuptools >=49.6.0              :  69.0.3 (OK)
sphinx >=0.6.6                   :  7.2.6 (OK)
spyder_kernels >=2.5.0,<2.6.0    :  2.5.0 (OK)
textdistance >=4.2.0             :  4.6.1 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  3.0.0 (OK)
zmq >=22.1.0                     :  25.1.2 (OK)

# Optional:
cython >=0.21                    :  None (NOK)
matplotlib >=3.0.0               :  3.8.2 (OK)
numpy >=1.7                      :  1.26.2 (OK)
pandas >=1.1.1                   :  2.1.4 (OK)
scipy >=0.17.0                   :  1.11.4 (OK)
sympy >=0.7.3                    :  None (NOK)
```



Discussion:
Same issue on my side. Might be because `os.environ.get('CONDA_EXE') or os.environ.get('MAMBA_EXE')` [from conda.py(140)find_conda()] return `None`. On my end, only `CONDA_PREFIX` key is available in `os.environ`.

Issue #21515 might have the same origin.
Hey @Stargrazer82301 and @mhabets, thanks for your feedback. We'll address this problem in our next version (5.5.1), to be released shortly.
> Issue https://github.com/spyder-ide/spyder/issues/21515 might have the same origin.

Yep, you're right. If you installed Anaconda, Miniconda, Miniforge or another conda-based distro in a non-standard location, we're unable to detect conda and run a lot of things related to it.

We're still unsure how to address that problem.

Resolving patch:
diff --git a/spyder/utils/conda.py b/spyder/utils/conda.py
--- a/spyder/utils/conda.py
+++ b/spyder/utils/conda.py
@@ -203,7 +203,7 @@ def get_spyder_conda_channel():
     conda = find_conda()
 
     if conda is None:
-        return None
+        return None, None
 
     env = get_conda_env_path(sys.executable)
     cmdstr = ' '.join([conda, 'list', 'spyder', '--json', '--prefix', env])
@@ -213,7 +213,7 @@ def get_spyder_conda_channel():
         out = out.decode()
         out = json.loads(out)
     except Exception:
-        return None
+        return None, None
 
     for package_info in out:
         if package_info["name"] == 'spyder':
diff --git a/spyder/workers/updates.py b/spyder/workers/updates.py
--- a/spyder/workers/updates.py
+++ b/spyder/workers/updates.py
@@ -115,7 +115,7 @@ def start(self):
         elif is_anaconda():
             channel, channel_url = get_spyder_conda_channel()
 
-            if channel_url is None:
+            if channel is None or channel_url is None:
                 return
             elif channel == "pypi":
                 self.url = pypi_url


Test patch: