Repository: spyder-ide/spyder

Issue:
Extra info displayed about Python interpreter in status bar
## Description

### What steps will reproduce the problem?

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

it creates only after the installation of the tesseract ocr in my system

### Traceback
```python-traceback
Traceback (most recent call last):
  File "c:\users\sanjay chakravarthy\appdata\local\programs\python\python37\lib\site-packages\spyder\plugins\completion\plugin.py", line 523, in update_completion_status
    value, _ = value.split('(')
ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "c:\users\sanjay chakravarthy\appdata\local\programs\python\python37\lib\site-packages\spyder\plugins\completion\plugin.py", line 523, in update_completion_status
    value, _ = value.split('(')
ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "c:\users\sanjay chakravarthy\appdata\local\programs\python\python37\lib\site-packages\spyder\plugins\completion\plugin.py", line 523, in update_completion_status
    value, _ = value.split('(')
ValueError: too many values to unpack (expected 2)
```

## Versions

* Spyder version: 5.3.2  (pip)
* Python version: 3.7.9 64-bit
* Qt version: 5.15.2
* PyQt5 version: 5.15.7
* Operating System: Windows 10

### Dependencies

```
# Mandatory:
atomicwrites >=1.2.0          :  1.4.1 (OK)
chardet >=2.0.0               :  5.0.0 (OK)
cloudpickle >=0.5.0           :  2.1.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.9.1 (OK)
keyring >=17.0.0              :  23.7.0 (OK)
nbconvert >=4.0               :  6.5.0 (OK)
numpydoc >=0.6.0              :  1.4.0 (OK)
paramiko >=2.4.0              :  2.11.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.1 (OK)
pygments >=2.0                :  2.12.0 (OK)
pylint >=2.5.0;<3.0           :  2.14.5 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.5.0;<1.6.0          :  1.5.0 (OK)
pylsp_black >=1.2.0           :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0     :  3.0.3 (OK)
qstylizer >=0.1.10            :  0.2.1 (OK)
qtawesome >=1.0.2             :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0      :  5.3.1 (OK)
qtpy >=2.1.0                  :  2.1.0 (OK)
rtree >=0.9.7                 :  1.0.0 (OK)
setuptools >=49.6.0           :  63.4.1 (OK)
sphinx >=0.6.6                :  5.1.1 (OK)
spyder_kernels >=2.3.2;<2.4.0 :  2.3.2 (OK)
textdistance >=4.2.0          :  4.3.0 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.9 (OK)
zmq >=22.1.0                  :  23.2.0 (OK)

# Optional:
cython >=0.21                 :  0.29.32 (OK)
matplotlib >=3.0.0            :  None (NOK)
numpy >=1.7                   :  1.21.6 (OK)
pandas >=1.1.1                :  1.3.5 (OK)
scipy >=0.17.0                :  None (NOK)
sympy >=0.7.3                 :  None (NOK)
```

### Environment

<details><summary>Environment</summary>

```
Package                       Version
----------------------------- -----------
-pyder                        5.3.2
alabaster                     0.7.12
altgraph                      0.17.2
arrow                         1.2.2
astroid                       2.11.7
atomicwrites                  1.4.1
attrs                         22.1.0
auto-py-to-exe                2.20.1
autopep8                      1.6.0
Babel                         2.10.3
backcall                      0.2.0
bcrypt                        3.2.2
beautifulsoup4                4.11.1
binaryornot                   0.4.4
black                         22.6.0
bleach                        5.0.1
bottle                        0.12.21
bottle-websocket              0.2.9
certifi                       2022.6.15
cffi                          1.15.1
chardet                       5.0.0
charset-normalizer            2.1.0
click                         8.1.3
cloudpickle                   2.1.0
colorama                      0.4.5
cookiecutter                  2.1.1
cryptography                  37.0.4
Cython                        0.29.32
DateTime                      4.5
debugpy                       1.6.2
decorator                     5.1.1
defusedxml                    0.7.1
diff-match-patch              20200713
dill                          0.3.5.1
docutils                      0.19
Eel                           0.14.0
entrypoints                   0.4
fastjsonschema                2.16.1
flake8                        4.0.1
future                        0.18.2
gevent                        21.12.0
gevent-websocket              0.10.1
greenlet                      1.1.2
idna                          3.3
imagesize                     1.4.1
importlib-metadata            4.12.0
importlib-resources           5.9.0
inflection                    0.5.1
intervaltree                  3.1.0
ipykernel                     6.15.1
ipython                       7.34.0
ipython-genutils              0.2.0
isort                         5.10.1
jedi                          0.18.1
jellyfish                     0.9.0
Jinja2                        3.1.2
jinja2-time                   0.2.0
jsonschema                    4.9.1
jupyter-client                7.3.4
jupyter-core                  4.11.1
jupyterlab-pygments           0.2.2
keyring                       23.7.0
langdetect                    1.0.9
lazy-object-proxy             1.7.1
MarkupSafe                    2.1.1
matplotlib-inline             0.1.3
mccabe                        0.6.1
mistune                       0.8.4
mypy-extensions               0.4.3
mysql-connector-python        8.0.29
nbclient                      0.6.6
nbconvert                     6.5.0
nbformat                      5.4.0
nest-asyncio                  1.5.5
numpy                         1.21.6
numpydoc                      1.4.0
opencv-python                 4.6.0.66
packaging                     21.3
pandas                        1.3.5
pandocfilters                 1.5.0
paramiko                      2.11.0
parso                         0.8.3
pathspec                      0.9.0
pefile                        2022.5.30
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        9.2.0
pip                           20.1.1
pkgutil-resolve-name          1.3.10
platformdirs                  2.5.2
pluggy                        1.0.0
prompt-toolkit                3.0.30
psutil                        5.9.1
ptyprocess                    0.7.0
pycodestyle                   2.8.0
pycparser                     2.21
pydocstyle                    6.1.1
pyflakes                      2.4.0
Pygments                      2.12.0
pyinstaller                   5.1
pyinstaller-hooks-contrib     2022.7
pylint                        2.14.5
pyls-spyder                   0.4.0
PyNaCl                        1.5.0
pyparsing                     3.0.9
PyQt5                         5.15.7
PyQt5-Qt5                     5.15.2
PyQt5-sip                     12.11.0
PyQtWebEngine                 5.15.6
PyQtWebEngine-Qt5             5.15.2
pyrsistent                    0.18.1
pytesseract                   0.3.9
python-dateutil               2.8.2
python-lsp-black              1.2.1
python-lsp-jsonrpc            1.0.0
python-lsp-server             1.5.0
python-slugify                6.1.2
pytoolconfig                  1.2.2
pytz                          2022.1
pywin32                       304
pywin32-ctypes                0.2.0
PyYAML                        6.0
pyzmq                         23.2.0
QDarkStyle                    3.0.3
qstylizer                     0.2.1
QtAwesome                     1.1.1
qtconsole                     5.3.1
QtPy                          2.1.0
requests                      2.28.1
rope                          1.3.0
Rtree                         1.0.0
setuptools                    63.4.1
six                           1.16.0
snowballstemmer               2.2.0
sortedcontainers              2.4.0
soupsieve                     2.3.2.post1
Sphinx                        5.1.1
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
spyder                        5.3.2
spyder-kernels                2.3.2
tesseract                     0.1.3
text-unidecode                1.3
textdistance                  4.3.0
three-merge                   0.1.1
tinycss2                      1.1.1
tkcalendar                    1.6.1
toml                          0.10.2
tomli                         2.0.1
tomlkit                       0.11.1
tornado                       6.2
traitlets                     5.3.0
typed-ast                     1.5.4
typing-extensions             4.3.0
ujson                         5.4.0
urllib3                       1.26.11
watchdog                      2.1.9
wcwidth                       0.2.5
webencodings                  0.5.1
whatthepatch                  1.0.2
whichcraft                    0.6.1
wrapt                         1.14.1
xlrd                          2.0.1
XlsxWriter                    3.0.3
yapf                          0.32.0
zipp                          3.8.0
zope.event                    4.5.0
zope.interface                5.4.0

```
</details>



Discussion:
Hi @SanjaiKr thank you for the feedback! Could you run spyder with the `debug-info` flag and post here the generated logs? For that you can run from the cmd something like `spyder --debug-info verbose`.

Let us know!
![Screenshot (47)](https://user-images.githubusercontent.com/110981812/184127085-10dd330e-77e5-4075-a396-b4b0e0cc6c3a.png)

There is no generated log this time, But it's the same error again
🤔 seems like the custom interpreter you are using is returning something strange as interpreter info (usually in the status bar you will only see something like `Completions: custom`). Could you run again Spyder with the following: `spyder --debug-info verbose --debug-output file`. Running with the `debug-output` should generated a `spyder-debug.log` file on the cmd current working directory.

I think the problem is in the way Spyder tries to get information from the interpreter (the logic is at `spyder.utils.programs.get_interpreter_info`) where we run the `-V` command with the path of the current interpreter but seems like when you install `tesseract` it changes somehow the output of running `-V` with the interpreter path. Could you try to check what is the path used with the `get_interpreter_info` function when the error happens:

https://github.com/spyder-ide/spyder/blob/1df174fb17bb3fe03c018310df2b6041a88fbd42/spyder/utils/programs.py#L1050-L1057

Let us know!
[spyder-debug1.log](https://github.com/spyder-ide/spyder/files/9314273/spyder-debug1.log)


here,s the log file and how i am supposed to get the path that you are asking,  I don't know that
@SanjaiKr thank you for the log file! To check the path you could add a `print` statement to the `get_interpreter_info` function that is in the file at `c:\users\sanjay chakravarthy\appdata\local\programs\python\python37\lib\site-packages\spyder\utils.programs.py` and generate again the log.

However, checking the .log file seems like the interpreter path being used is `c:\\users\\sanjay chakravarthy\\appdata\\local\\programs\\python\\python37\\python.exe`

What happens if you run from cmd `c:\\users\\sanjay chakravarthy\\appdata\\local\\programs\\python\\python37\\python.exe -V`? You get `Python 3.7.9` or something else?

Let us know!
@dalthviz, perhaps we could detect if the text that we get from `python -V` is in the form of `Python x.x.x` and if not fallback to not reporting the version.
Python 3.7.9

I'm getting this...

And i am unable to add a print statement in that file, If i did then the spyder not even starts...

Resolving patch:
diff --git a/spyder/utils/programs.py b/spyder/utils/programs.py
--- a/spyder/utils/programs.py
+++ b/spyder/utils/programs.py
@@ -1052,6 +1052,11 @@ def get_interpreter_info(path):
     try:
         out, __ = run_program(path, ['-V']).communicate()
         out = out.decode()
+
+        # This is necessary to prevent showing unexpected output.
+        # See spyder-ide/spyder#19000
+        if not re.search(r'^Python \d+\.\d+\.\d+$', out):
+            out = ''
     except Exception:
         out = ''
     return out.strip()


Test patch: