TypeError: expected string or bytes-like object while starting Spyder 5.2.2

Question:

I created a new environment in conda with Spyder 5.2.2 and Python 3.10.2. Now, I’m experiencing an error telling me that the program expects a string or byte-like object while starting the Spyder. Interestingly, this does not happen when my Python is 3.9.* . Any reason this can happen?

Here is the error encountered:

(py10) PS C:UsersKevin Yew> spyder
Traceback (most recent call last):
  File "C:UsersKevin Yewanaconda3envspy10Scriptsspyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:UsersKevin Yewanaconda3envspy10libsite-packagesspyderappstart.py", line 233, in main
    from spyder.app import mainwindow
  File "C:UsersKevin Yewanaconda3envspy10libsite-packagesspyderappmainwindow.py", line 41, in <module>
    requirements.check_qt()
  File "C:UsersKevin Yewanaconda3envspy10libsite-packagesspyderrequirements.py", line 47, in check_qt
    if parse_version(actual_ver) < parse_version(required_ver):
  File "C:UsersKevin Yewanaconda3envspy10libsite-packagespkg_resources__init__.py", line 120, in parse_version
    return packaging.version.Version(v)
  File "C:UsersKevin Yewanaconda3envspy10libsite-packagespkg_resources_vendorpackagingversion.py", line 264, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object

Edit
Here’s the code you can try to reproduce the error.

conda create -n py10 python=3.10.2
conda activate py10
conda install spyder
spyder
Asked By: user16836078

||

Answers:

I have glanced through the posts about the issues in Spyder and apparently, it involves upgrading or downgrading certain packages to solve the problem of running Spyder. When I look into the updatable packages in Anaconda Navigator, the PyQt and Qt are not in the latest release. I tried my luck to update it to the latest version and now the Spyder works! Now I can run my Spyder with Python 3.10.2 🙂

Answered By: user16836078

(Spyder maintainer here) This is an error in the code that checks if PyQt5 is present and it will be fixed in our next version (5.3.0) to be released in March 2022 (see here).

Answered By: Carlos Cordoba

I resolved this running:

conda install -c anaconda pyqt
Answered By: Ohumeronen