How to get D4RL to work on machines

Execute:

- pip install gym==0.26.2

1.)
#####
you can use a modern version of gym with d4rl but need to modify

file name: /usr/local/Caskroom/miniconda/envs/newenv/lib/python3.10/site-packages/pybullet_envs/__init__.py

functions edited:
    (func) register: imported registry object is now a dict with keys corresponding to id so (modification on line 6)
            
        from "if id in registry.env_specs"
        to   "if id in registry"

########


2.)
##########
edit the Class NormalizedBoxEnv in d4rl to be compatible with new gym (outputting a variable for trunc)

file name: ~/d4rl/d4rl/utils/wrappers.py

Class edited:
    (class (Normalized Box Env), method) step: modified output on lines 165 and 168 to assign a value to trunc
########


3.)
#########
edit method "step" in Class "TimeLimit" to output truncated variable (class starts line 39)

code:
"""
        try:
            observation, reward, terminated, truncated, info = self.env.step(action)
        except ValueError:
            truncated = False
            observation, reward, terminated, info = self.env.step(action)

        self._elapsed_steps += 1

        if self._elapsed_steps >= self._max_episode_steps:
            truncated = True

        return observation, reward, terminated, truncated, info
"""

file name: ~/miniconda3/envs/diffenv/lib/python3.10/site-packages/gym/wrappers/time_limit.py
############

4.)
#######
edit __init__ method in class AntEnv to inlcude argument for observation_space

code:
"""
    obs_space = spaces.Box(np.inf,-np.inf,shape=(29,))
    mujoco_env.MujocoEnv.__init__(self, file_path, 5, observation_space=obs_space)
"""

filename: ~/miniconda3/envs/diffenv/lib/python3.10/site-packages/d4rl/locomotion/ant.py

(also need to import spaces "from gym import utils, spaces")
#########

5.)
#######
Comment out lines 61-68 in filename: ~/miniconda3/envs/diffenv/lib/python3.10/site-packages/gym/envs/mujoco/mujoco_env.py
######

6.)
#####
In file: miniconda3/envs/diffenv/lib/python3.10/site-packages/d4rl/locomotion/ant.py

change: "self.np_random.randn(self.model.nv)"
to: "self.np_random.random(self.model.nv)"

Line number 124


Also in same file: 
Comment out "return self.sim" lines 62-64

Again in same file:
Replace attribute "self.physics.data" with "self.data" lines 95, 96, 100, 101, 141, 144, 147

Replace attribute "self.sim.data" with "self.data" line 77
