Search code examples
pythonspyderminiconda

Module "pygments.lexer" not found when running Spyder from miniconda


I was following the install tutorial in Spyder webpage and apparently I was able to install it without errors with the command: conda install -c conda-forge spyder numpy scipy pandas matplotlib sympy cython

I ran this inside a newly created environment. I also ran conda update --all. However when I try to run spyder, I get the following:

Traceback (most recent call last):
  File "...\MiniConda3\envs\dados\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "...\MiniConda3\envs\dados\Lib\site-packages\spyder\app\start.py", line 132, in main
    from spyder.config.manager import CONF
  File "...\MiniConda3\envs\dados\Lib\site-packages\spyder\config\manager.py", line 22, in <module>
    from spyder.config.main import CONF_VERSION, DEFAULTS, NAME_MAP
  File "...\MiniConda3\envs\dados\Lib\site-packages\spyder\config\main.py", line 21, in <module>
    from spyder.config.appearance import APPEARANCE
  File "...\MiniConda3\envs\dados\Lib\site-packages\spyder\config\appearance.py", line 15, in <module>
    from spyder.plugins.help.utils.sphinxify import CSS_PATH
  File "...\MiniConda3\envs\dados\Lib\site-packages\spyder\plugins\help\utils\sphinxify.py", line 37, in <module>
    from sphinx.application import Sphinx
  File "...\MiniConda3\envs\dados\Lib\site-packages\sphinx\application.py", line 21, in <module>
    from pygments.lexer import Lexer  # NoQA: TCH002
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pygments.lexer'

conda --version = 24.4.0 and python --version = 3.12.3. I also see the version 2.18.0 of package pygments present. Any ideas about the issue?


Solution

  • Not exactly the most elegant solution, but since it did the trick, it was a solution. conda uninstall spyder conda install spyder made it work.