-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Hi,
I just started looking into that repo and went into troubles when trying to import the package in Python. I set up a new virtual environment with only whynot and dependencies installed (Python 3.8.14). Then, when running
import whynot as wn , I get the following error:
ImportError Traceback (most recent call last)
Cell In [2], line 4
1 import matplotlib.pyplot as plt
2 import numpy as np
----> 4 import whynot as wn
5 import whynot.gym as gym
7 import scripts.utils as utilsFile ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/init.py:5
3 version = "0.12.0"
4 from whynot.algorithms import *
----> 5 from whynot.simulators import *
6 from whynot import causal_graphs, dynamics, framework
7 from whynot.dynamics import (
8 DynamicsExperiment,
9 Run,
10 )File ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/simulators/init.py:4
1 """Simulator initialization."""
3 from whynot.simulators import civil_violence
----> 4 from whynot.simulators import credit
5 from whynot.simulators import delayed_impact
6 from whynot.simulators import diceFile ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/simulators/credit/init.py:15
3 from whynot.simulators.credit.simulator import (
4 agent_model,
5 Config,
(...)
10 State,
11 )
13 from whynot.simulators.credit.dataloader import CreditData
---> 15 from whynot.simulators.credit.environments import *
17 SUPPORTS_CAUSAL_GRAPHS = TrueFile ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/simulators/credit/environments.py:4
1 """Interactive environment for the credit simulator."""
2 import numpy as np
----> 4 from whynot.gym import spaces
5 from whynot.gym.envs import ODEEnvBuilder, register
6 from whynot.simulators.credit import (
7 agent_model,
8 CreditData,
(...)
13 State,
14 )File ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/gym/init.py:12
9 from gym.core import Env
10 from gym import logger
---> 12 from whynot.gym.envs import make, spec, register
14 all = ["Env", "make", "spec", "register"]File ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/gym/envs/init.py:3
1 """Environments based on WhyNot simulators."""
----> 3 from whynot.gym.envs.registration import registry, register, make, spec
4 from whynot.gym.envs.ode_env import ODEEnvBuilderFile ~/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/whynot/gym/envs/registration.py:4
1 """Global registry of environments, for consistency with openai gym."""
2 import importlib
----> 4 from gym.envs.registration import EnvRegistry
6 # Keep for consistency with original API
7 # pylint:disable-msg=invalid-name
8 # Have a global registry
9 registry = EnvRegistry()ImportError: cannot import name 'EnvRegistry' from 'gym.envs.registration' (/Users/.../opt/miniconda3/envs/testenv/lib/python3.8/site-packages/gym/envs/registration.py)
Because this seems to be related to gym (by default version 0.26.2 got installed), I tried out different gym versions and indeed with gym version 0.23.0 or lower the import works. So maybe, a quick-fix could be to restrict the gym version. It seems that from version 0.24.0 onwards, the gym registry module/API got changed causing an issue when importing whynot.
Having gym 0.23.0 installed, allows me to run the performative prediction example, which is what I'm currently interested in. However, in the walkthrough example there still occurs an error when running the simulator of world3:
dataset = experiment.run(num_samples=200, seed=1234, show_progress=True)
RuntimeError: Native library not available at /Users/mgorecki/opt/miniconda3/envs/testenv/lib/python3.8/site-packages/py_mini_racer/libmini_racer.dylib
I couldn't resolve that so far.