question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ContextualVersionConflict when using from_numpyro

See original GitHub issue

Describe the bug This is the strangest thing and I haven’t been able to entirely work out what’s going on but perhaps y’all have thoughts!

When using Google colab, I install numpyro with --no-deps so that it doesn’t try to update JAX to the CPU-only version. Then, everything runs fine (the sampler runs and I get my trace) until I execute az.from_numpyro(), at which point it blows up with the following exception:

ContextualVersionConflict                 Traceback (most recent call last)

<ipython-input-3-0b6cc67427eb> in <module>()
----> 1 data = az.from_numpyro(mcmc)

9 frames

/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
    773                 # Oops, the "best" so far conflicts with a dependency
    774                 dependent_req = required_by[req]
--> 775                 raise VersionConflict(dist, req).with_context(dependent_req)
    776 
    777             # push the new requirements onto the stack

ContextualVersionConflict: (jax 0.2.6 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('jax==0.2.3'), {'numpyro'})

This doesn’t really seem to be an ArviZ issue, but everything is fine until I try to use ArviZ so perhaps you have thoughts.

To Reproduce In a factor reset colab environment I run the following and get the above exception on the last line:

!pip install --no-deps numpyro
!pip install arviz

import arviz as az
import numpyro
import jax

def model():
    numpyro.sample("x", numpyro.distributions.Normal(0, 1))

mcmc = numpyro.infer.MCMC(numpyro.infer.NUTS(model), 1000, 1000, num_chains=4)
mcmc.run(jax.random.PRNGKey(34923))

data = az.from_numpyro(mcmc)

Expected behavior I would expect this exception to be thrown earlier if it is actually a problem, or for ArviZ to run as expected!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ColCarrollcommented, Nov 30, 2020

Wow! Can repro, and can confirm that the same behavior happens with PRNGKey 86074.

More seriously, the bug happens here, when trying to grab the library version to stamp the inference data. This definitely shouldn’t raise, and indicates that we’re doing something wrong with pkg_resources, and maybe with lazy-loading libraries.

Shorter term, if you import numpyro before arviz, it works fine.

0reactions
OriolAbrilcommented, Nov 23, 2022

Is this still happening?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve: "ContextualVersionConflict" on Python?
I was trying to run scanpy's neighbors function with my genes ... to load due to 'ContextualVersionConflict((llvmlite 0.33.0+1.g022ab0f ...
Read more >
mlagents-learn ContextualVersionConflict error related to ...
I needed to upgrade setuptools before the mlagents-learn script worked for me. It seems like that should have automatically been handled as ...
Read more >
Program uninstalled but still gives error - Ask Ubuntu
I had the same issue and I fixed it with the solution posted here. The “cryptography” had to be upgraded. I used pip...
Read more >
Problem with python dependances when I process tractoflow
Hi all, I'm facing a python package conflict (statsmodels 0.12.1 instead of 0.11.* and python-dateutil 2.7.2 instead of 2.7.3, cf.
Read more >
Need help: How to solve ContextualVersionConflict in vaex use
It works :D # Install vaex. !pip install vaex==3.0.0 # Reload pkg_resources. import importlib import pkg_resources importlib.reload(pkg_resources) # Import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found