Colaboratory:如何安装 PyGame 学习环境
Colaboratory: how to install PyGame Learning Environment
在 Colaboratory 中,我们被迫使用 pip install。 gym、PLE等一些第三方包,它们的安装应该是
git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
cd PyGame-Learning-Environment/
pip install -e .
当我尝试时,出现了一些问题:
1) !cd
在这里不起作用。我仍在 google 驱动器中的当前文件夹中。
2) 相反,我直接 运行:
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
!pip install -e PyGame-Learning-Environment
它说安装成功,但我无法导入它。我检查了一下,它没有出现在 /usr/local/lib/python3.6/dist-packages
中
我还通过以下方式检查了 python:
import os
print(os.getcwd())
这给了我:/content
,一个我不明白的目录。显然我无法导入包。
我该怎么办?
这是一个有效的例子:
https://colab.research.google.com/drive/1PsPArPkxnhCIKSFK2gDA46_vnLMc1U9z
提示:
- 使用
os.chdir
而不是 !cd
。 !
命令在子 shell 中执行,因此它们的效果不会应用于后续命令。 os.chdir
但是会。
- 您想检查
sys.path
而不是 site-packages,因为您正在使用 -e
进行安装。
- 您还需要安装
pygame
。看起来这是一个未列出的部门。
完整安装方法:
import os
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
os.chdir('PyGame-Learning-Environment')
!pip install -e .
!pip install pygame
os.chdir('/content')
在 Colaboratory 中,我们被迫使用 pip install。 gym、PLE等一些第三方包,它们的安装应该是
git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
cd PyGame-Learning-Environment/
pip install -e .
当我尝试时,出现了一些问题:
1) !cd
在这里不起作用。我仍在 google 驱动器中的当前文件夹中。
2) 相反,我直接 运行:
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
!pip install -e PyGame-Learning-Environment
它说安装成功,但我无法导入它。我检查了一下,它没有出现在 /usr/local/lib/python3.6/dist-packages
我还通过以下方式检查了 python:
import os
print(os.getcwd())
这给了我:/content
,一个我不明白的目录。显然我无法导入包。
我该怎么办?
这是一个有效的例子: https://colab.research.google.com/drive/1PsPArPkxnhCIKSFK2gDA46_vnLMc1U9z
提示:
- 使用
os.chdir
而不是!cd
。!
命令在子 shell 中执行,因此它们的效果不会应用于后续命令。os.chdir
但是会。 - 您想检查
sys.path
而不是 site-packages,因为您正在使用-e
进行安装。 - 您还需要安装
pygame
。看起来这是一个未列出的部门。
完整安装方法:
import os
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
os.chdir('PyGame-Learning-Environment')
!pip install -e .
!pip install pygame
os.chdir('/content')