openAI gym 实际应用中出现Attribute Error: module 'gym' has no attribute 'make'

安装gym后我们可以看见目录中有名为“gym”的文件夹,gym文件夹中还会有一个gym文件夹,如下图所示

假如我们在这个目录下python,测试import gym gym.__file__是可以成功的,但是出了这个目录就会出现Attribute Error: module 'gym' has no attribute 'make'

出现这个原因是我们在Unix中,gym的调用其实是和环境绑定的,虽然它有实际的文件夹,但是并不意味着你在某个环境下安装后,其他所有的环境都是共享的。

比如我有三个环境,env1,env2,env3,

我们是在env2的环境下安装的gym,则我们只有在source activate env2,在env2环境下,才能在任意目录下顺利执行

$ python
>>> import gym
>>> gym.__file__

在env1和env3中,我们import gym会No module named 'gym'; 假如到gym的目录下执行,就会出现Attribute Error: module 'gym' has no attribute 'make'

猜你喜欢

转载自www.cnblogs.com/starryxsky/p/10106011.html