Colaboratory: how to install PyGame Learning Environment
Question:
In Colaboratory, we are forced to use pip install. Some third packages such as gym, PLE, etc, their installation should be
git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
cd PyGame-Learning-Environment/
pip install -e .
When I tried, here are some problems:
1) !cd
doesn’t work here. I’m still in my current folder in google drive.
2) Instead, I directly run:
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
!pip install -e PyGame-Learning-Environment
And it says successfully installed, but I cannot import it. I checked and it doesnt appear in the /usr/local/lib/python3.6/dist-packages
I also checked the python by:
import os
print(os.getcwd())
which gives me: /content
, a directory I dont understand. And obviously I cannot import the package.
What should I do?
Answers:
Here’s a worked example:
https://colab.research.google.com/drive/1PsPArPkxnhCIKSFK2gDA46_vnLMc1U9z
Tips:
- Use
os.chdir
instead of !cd
. !
commands execute in a subshell, so their effects won’t apply to subsequent commands. os.chdir
will, however.
- You want to check
sys.path
instead of site-packages since you’re installing with -e
.
- You’ll also need to install
pygame
. It looks like that’s an unlisted dep.
Full install recipe:
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')
I could install like this.
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
!cd PyGame-Learning-Environment/ && pip install .
!pip install -q pygame
It can be checked like this.
!pip freeze | grep ple
--- Result ---
etuples==0.3.8
multipledispatch==0.6.0
ple @ file:///content/PyGame-Learning-Environment
from ple import PLE
--- Result ---
pygame 2.1.2 (SDL 2.0.16, Python 3.7.15)
Hello from the pygame community. https://www.pygame.org/contribute.html
couldn't import doomish
Couldn't import doom
In Colaboratory, we are forced to use pip install. Some third packages such as gym, PLE, etc, their installation should be
git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
cd PyGame-Learning-Environment/
pip install -e .
When I tried, here are some problems:
1) !cd
doesn’t work here. I’m still in my current folder in google drive.
2) Instead, I directly run:
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
!pip install -e PyGame-Learning-Environment
And it says successfully installed, but I cannot import it. I checked and it doesnt appear in the /usr/local/lib/python3.6/dist-packages
I also checked the python by:
import os
print(os.getcwd())
which gives me: /content
, a directory I dont understand. And obviously I cannot import the package.
What should I do?
Here’s a worked example:
https://colab.research.google.com/drive/1PsPArPkxnhCIKSFK2gDA46_vnLMc1U9z
Tips:
- Use
os.chdir
instead of!cd
.!
commands execute in a subshell, so their effects won’t apply to subsequent commands.os.chdir
will, however. - You want to check
sys.path
instead of site-packages since you’re installing with-e
. - You’ll also need to install
pygame
. It looks like that’s an unlisted dep.
Full install recipe:
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')
I could install like this.
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
!cd PyGame-Learning-Environment/ && pip install .
!pip install -q pygame
It can be checked like this.
!pip freeze | grep ple
--- Result ---
etuples==0.3.8
multipledispatch==0.6.0
ple @ file:///content/PyGame-Learning-Environment
from ple import PLE
--- Result ---
pygame 2.1.2 (SDL 2.0.16, Python 3.7.15)
Hello from the pygame community. https://www.pygame.org/contribute.html
couldn't import doomish
Couldn't import doom