Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError in jsonschema #329

Closed
ans6160 opened this issue Sep 29, 2023 · 3 comments
Closed

AttributeError in jsonschema #329

ans6160 opened this issue Sep 29, 2023 · 3 comments

Comments

@ans6160
Copy link

ans6160 commented Sep 29, 2023

Hi,

I just installed pyslim to use with msprime and when I import pyslim, I am hit with tracebacks and an attribute error:

>>> import pyslim Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/pyslim/__init__.py", line 4, in <module> from pyslim.slim_metadata import * # NOQA ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/pyslim/slim_metadata.py", line 438, in <module> slim_metadata_schemas = {k: tskit.MetadataSchema(_raw_slim_metadata_schemas[k]) for k in _raw_slim_metadata_schemas} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/pyslim/slim_metadata.py", line 438, in <dictcomp> slim_metadata_schemas = {k: tskit.MetadataSchema(_raw_slim_metadata_schemas[k]) for k in _raw_slim_metadata_schemas} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/tskit/metadata.py", line 639, in __init__ codec_instance = codec_cls(schema) ^^^^^^^^^^^^^^^^^ File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/tskit/metadata.py", line 580, in __init__ StructCodecSchemaValidator.check_schema(schema) File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/jsonschema/validators.py", line 301, in check_schema for error in validator.iter_errors(schema): File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/jsonschema/validators.py", line 368, in iter_errors for error in errors: File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/tskit/metadata.py", line 196, in binary_format_validator yield from jsonschema._validators.type(validator, types, instance, schema) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/jsonschema/__init__.py", line 105, in __getattr__ raise AttributeError(f"module {__name__} has no attribute {name}") AttributeError: module jsonschema has no attribute _validators. Did you mean: 'validators'?

pyslim version: 1.0.4
msprime version: 1.2.0

I am not sure how to resolve this issue. Any help would be greatly appreciated!

-Abby

@bhaller
Copy link
Collaborator

bhaller commented Sep 29, 2023

Hi! There has been discussion of this on the tskit Slack recently. That discussion said:

Not sure in which repo it needs to go as an issue but I think I've stumbled on a version incompatibility with jsonschema.
Got this error trying to import pyslim in an environment but it seems the culprit is tskit. This issue seems to be from this change in jsonschema https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst#v4190, so reverting to v4.18.6 works.

Here is the tskit issue that was opened:

tskit-dev/tskit#2840

So for now you can resolve this by reverting to an older jsonschema, and you may wish to watch that other issue to see what happens with it. @petrelharp I'll leave this for you to close as you wish.

@jiseonmin
Copy link
Contributor

Hi, I ran into the same issue. Running pip install jsonschema==4.18.6, as suggested above, solved it!

@petrelharp
Copy link
Contributor

Yep, thanks, all! This is an upstream issue with tskit (we can tell because the last packagereferenced before jsonschema is tskit:)

File "/Users/ans6160/anaconda3/envs/msprime/lib/python3.11/site-packages/tskit/metadata.py", line 580, in __init__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants