我设法在PyCharm项目中安装了OpenAI Gym Atari环境。 (花了很多时间反复试验,我不知道是什么最终使它起作用。但是现在可以了。)
我复制了项目目录,从该副本创建了另一个项目,然后尝试运行之前运行的相同程序-实际上是我复制目录时创建的程序的副本。现在,我收到一条错误消息,提示未安装Atari环境-或未正确安装。
Traceback (most recent call last):
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 9, in <module>
import atari_py
ModuleNotFoundError: No module named 'atari_py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/rabbott/Google Drive/CSULA/ECST/CS Dept/CS 4660/2018/OpenAI_Models/Q-Learning-Framework - Copy/Interactive_Atari-2018-10-27-2230.py", line 416, in <module>
GameControl(Bot()).play('Pong-v0')
File "C:/Users/rabbott/Google Drive/CSULA/ECST/CS Dept/CS 4660/2018/OpenAI_Models/Q-Learning-Framework - Copy/Interactive_Atari-2018-10-27-2230.py", line 30, in play
env = gym.make(game)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 167, in make
return registry.make(id)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 119, in make
env = spec.make()
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 85, in make
cls = load(self._entry_point)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 14, in load
result = entry_point.load(False)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2324, in load
return self.resolve()
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2330, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\__init__.py", line 1, in <module>
from gym.envs.atari.atari_env import AtariEnv
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 11, in <module>
raise error.DependencyNotInstalled("{}. (HINT: you can install Atari dependencies by running 'pip install gym[atari]'.)".format(e))
gym.error.DependencyNotInstalled: No module named 'atari_py'. (HINT: you can install Atari dependencies by running 'pip install gym[atari]'.)
Process finished with exit code 1
当我尝试再次安装它时,遇到了最初遇到的相同问题。特别是,我不知道如何正确安装Atari环境。
是否存在一些相对简单的方法来使用已在项目副本中运行的安装?
谢谢。
答案 0 :(得分:0)
安装健身房和进行工作的最安全方法是使用python虚拟环境。为您的健身项目提供单独的虚拟环境总是更好。请使用conda或pipenv创建一个虚拟环境。
pipenv中的示例
安装pipenv
pip install --user pipenv
进入项目目录(您的.py文件所在的目录)
cd myproject
安装健身室
pipenv install gym
如下所示在您的虚拟环境中安装atari和任何其他依赖项。
pipenv install atari-py
运行您的代码
pipenv run python main.py
这将确保您的代码正常工作。
注意
Pipenv 为每个项目创建不同的虚拟环境。如果要对多个项目使用同一环境,请使用上述 conda 中的虚拟环境。