Mac系统在Pycharm终端 安装Gym和Pytorch

安装Gym

高版本的会报错

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gym==0.21.0

测试代码

import gym
env = gym.make('CartPole-v1')
for i_episode in range(20):
    observation = env.reset()
    for t in range(100):
        env.render()
        print(observation)
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break
env.close()

根据命令号报错提示再安装pyglet 

pip install pyglet

再运行示例代码,即可显示环境 

安装pytorch

PyTorch

官网找指令

conda install pytorch torchvision torchaudio -c pytorch

你可能感兴趣的:(python,macos,pycharm,python)