ModuleNotFoundError: No module named 'jsonschema.compat'

Question:

I have been working with the Bybit API for the last week when I encountered the title problem yesterday. I have started a new env and installed only the bybit wrapper again and the issue still arises. From what I can see I have jsonschema installed and in my env PATH. It was working a few days ago, so I do believe this to be separate from whatever API I am trying to use. Included is a picture of the response when run in an interpreter. Any help would be greatly appreciated.

ModuleNotFoundError: No module named ‘jsonschema.compat’ is the error that comes up.

enter image description here

Asked By: Bjorgum

||

Answers:

I have exactly the same problem! It was working before the release of 1.3, with the version 1.21 months a go.
I found this problem to day after updateing my venv to the newest versions.
Search a little more, it is a problem with the version of the jsonschema-4.0.1, go back to version 3.1.1 of jsonschema and all is running like befor, incl. the version 1.3 of bybit.
Regards,

Answered By: Georges Grey

That module was removed in jsonschema 4.0. Your packages haven’t been pinned to only use jsonschema 3.x, so that might happen.

For now, you can downgrade to version 3.x of the jsonschema package with

pip install -U 'jsonschema<4.0'

and things should work.

Answered By: AKX

I was having the same issue too, but in my case the library which has the requirement of jsonschema was bitmex. I downgraded the package on my requirement.txt constraining the version:

jsonschema<4.0

For those who use conda

conda update "jsonschema<4.0"

or mamba

mamba update "jsonschema<4.0"

install instead of update will just say that already installed.

Fixes

from jsonschema.protocols import Validator
ModuleNotFoundError: No module named 'jsonschema.protocols'

as well.

Answered By: MosQuan
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.