spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.2k stars 1.59k forks source link

Spyder sometimes open sometimes don't with lots of tracebacks #22310

Open shimakazexkaki opened 1 month ago

shimakazexkaki commented 1 month ago

Description

What steps will reproduce the problem?

Can't actually tell what will reproduce the problem since each time the traceback log and Error are different. Tried spyder --reset. Usually the first time it worked and crashed after sometime. Below is the last time traceback log, Spyder didn't open when this comes out. I guess it's about Spyder's plugins? Because initially it tells me something went wrong in Spyder.ini , I go change some settings compare to my other computer whose Spyder works fine and it worked but crashes later. Oh, Spyder can't open especially on this env, but opens well on some other env Not familiar with GitHub's format but willing to change it if I know how.

Traceback

Traceback (most recent call last):
  File "/home/lab688/work/anaconda3/envs/matlab/bin/spyder", line 8, in <module>
    sys.exit(main())
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/start.py", line 232, in main
    from spyder.app import mainwindow
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 69, in <module>
    from spyder.app.find_plugins import (
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/find_plugins.py", line 19, in <module>
    from spyder.api.plugins import (
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/api/plugins/__init__.py", line 25, in <module>
    from .old_api import SpyderPlugin, SpyderPluginWidget  # noqa
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/api/plugins/old_api.py", line 21, in <module>
    from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/plugins/base.py", line 24, in <module>
    from spyder.config.gui import get_color_scheme, get_font
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/config/gui.py", line 31, in <module>
    from spyder.utils import syntaxhighlighters as sh
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/utils/syntaxhighlighters.py", line 976, in <module>
    class NsisSH(CppSH):
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/utils/syntaxhighlighters.py", line 979, in NsisSH
    PROG = re.compile(make_nsis_patterns(), re.S)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/re.py", line 236, in compile
    return _compile(pattern, flags)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/re.py", line 288, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/sre_compile.py", line 768, in compile
    code = _code(p, flags)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/sre_compile.py", line 607, in _code
    _compile(code, p.data, flags)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/sre_compile.py", line 209, in _compile
    _compile(code, av, flags)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/sre_compile.py", line 168, in _compile
    _compile(code, p, _combine_flags(flags, add_flags, del_flags))
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/sre_compile.py", line 209, in _compile
    _compile(code, av, flags)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/sre_compile.py", line 91, in _compile
    if op in LITERAL_CODES:
UnboundLocalError: local variable 'op' referenced before assignment

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.3 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0;<8.0.0        :  7.31.1 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.11.2 (OK)
jsonschema >=3.2.0            :  4.4.0 (OK)
keyring >=17.0.0              :  23.4.0 (OK)
nbconvert >=4.0               :  6.4.4 (OK)
numpydoc >=0.6.0              :  1.2 (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.8.0 (OK)
pygments >=2.0                :  2.11.2 (OK)
pylint >=2.5.0                :  2.7.4 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.3.2;<1.4.0          :  1.3.3 (OK)
pylsp_black >=1.0.0           :  1.0.0 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.3 (OK)
qtconsole >=5.2.1;<5.3.0      :  5.2.2 (OK)
qtpy >=1.5.0                  :  2.0.1 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  61.2.0 (OK)
sphinx >=0.6.6                :  4.3.2 (OK)
spyder_kernels >=2.2.1;<2.3.0 :  2.2.1 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
xdg >=0.26                    :  0.27 (OK)
zmq >=17                      :  25.0.2 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=2.0.0            :  3.4.3 (OK)
numpy >=1.7                   :  1.21.5 (OK)
pandas >=1.1.1                :  1.1.5 (OK)
scipy >=0.17.0                :  1.7.3 (OK)
sympy >=0.7.3                 :  None (NOK)
ccordoba12 commented 1 month ago

Hey @shimakazexkaki, thanks for reporting. This problem should be fixed in our latest version available in Anaconda (5.5.1). Please update by closing Spyder, opening the Anaconda Prompt and running there the commands mentioned in our documentation.

Let us know if it works for you.

shimakazexkaki commented 1 month ago

@ccordoba12 Thanks for response ! I tried sudo apt install spyder ,since I am using in a env and I am not allowed to update conda in base, and after it finishes it went well. But after multiple times opening and closing Spyder this error pops out and Spyder didn't open this time. Is there any other solutions for updating Spyder in a env?

(matlab) lab688@lab688-System-Product-Name:~$ spyder
Traceback (most recent call last):
  File "/home/lab688/work/anaconda3/envs/matlab/bin/spyder", line 8, in <module>
    sys.exit(main())
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/start.py", line 236, in main
    mainwindow.main(options, args)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 2016, in main
    mainwindow = create_window(MainWindow, app, splash, options, args)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/utils.py", line 289, in create_window
    main.setup()
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 848, in setup
    internal_plugins = find_internal_plugins()
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/app/find_plugins.py", line 92, in find_internal_plugins
    mod = importlib.import_module(entry_point.module_name)
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/plugins/editor/plugin.py", line 49, in <module>
    from spyder.plugins.editor.widgets.editor import (EditorMainWindow,
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/plugins/editor/widgets/editor.py", line 42, in <module>
    from spyder.plugins.editor.widgets import codeeditor
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/spyder/plugins/editor/widgets/codeeditor.py", line 31, in <module>
    from IPython.core.inputtransformer2 import TransformerManager
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/IPython/__init__.py", line 56, in <module>
    from .terminal.embed import embed
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 19, in <module>
    from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
    from .application import Application
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/application/__init__.py", line 1, in <module>
    from .application import Application
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 42, in <module>
    from prompt_toolkit.buffer import Buffer
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/buffer.py", line 46, in <module>
    from .search import SearchDirection, SearchState
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/search.py", line 13, in <module>
    from .key_binding.vi_state import InputMode
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/key_binding/__init__.py", line 1, in <module>
    from .key_bindings import (
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 54, in <module>
    from prompt_toolkit.keys import KEY_ALIASES, Keys
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/site-packages/prompt_toolkit/keys.py", line 10, in <module>
    class Keys(str, Enum):
  File "/home/lab688/work/anaconda3/envs/matlab/lib/python3.7/enum.py", line 236, in __new__
    if canonical_member._value_ == enum_member._value_:
AttributeError: type object 'EnumMeta' has no attribute '_value_'
ccordoba12 commented 1 month ago

It seems your matlab env is broken and you need to recreate it. Do you need to use Python 3.7? Or you can use a more recent version?

shimakazexkaki commented 1 month ago

I have to use Python 3.7 unfortunately, but I will try recreating envs. Thanks for response!

ccordoba12 commented 1 month ago

Ok, then I suggest you use this command for that:

conda create -n matlab-new -c conda-forge python=3.7 spyder

That will use the Linux Conda-forge packages, which are better maintained than the ones coming from Anaconda.

If you need to install more packages in that environment (e.g. Pandas), you need to run

conda install -c conda-forge pandas

Let us know if it works for you.