强化学习环境搭建之gym安装

环境anaconda-env-python3.8

安装gym的两种方式:

1、

git clone https://github.com/openai/gym.git
cd gym
pip install -e '.[all]'

2、

pip install gym[all]

我使用方式2安装,

1、报错mujoco找不到,严格按照(https://www.jianshu.com/p/869254fd3e21)安装mujoco
2、报错fatal error: GL/osmesa.h: No such file or directory,解决:sudo apt install libosmesa6-dev
3、报错error: command 'swig' failed with exit status 1,解决:sudo apt-get install swig
4、报错ImportError: can't import name 'rendering' from 'gym.envs.classic_control',从[gym仓库](https://github.com/openai/gym/tree/0cd9266d986d470ed9c0dd87a41cd680b65cfe1c/gym/envs/classic_control)复制rendering.py到对应的路径即可解决
4、其他问题,参考 https://zhuanlan.zhihu.com/p/124001142
5、终于搞定啦!!!

gym测试程序:

import gym
env = gym.make("CartPole-v1")
observation = env.reset()
for _ in range(1000):
  env.render()
  action = env.action_space.sample() # your agent here (this takes random actions)
  observation, reward, done, info = env.step(action)

  if done:
    observation = env.reset()
env.close()

jupyter使用虚拟环境

conda install conda_nb
conda install jupyter

由于网络问题,报错:Downloaded bytes did not match Content-Length。解决:https://blog.csdn.net/feifei3211/article/details/80361227

你可能感兴趣的:(环境搭建,python,reinforcement,learning)