deep-rl-class icon indicating copy to clipboard operation
deep-rl-class copied to clipboard

[HANDS-ON BUG] - Installing pickle5

Open nikunjkakadiya2010 opened this issue 7 months ago • 2 comments

Describe the bug

I am trying to run the hand on notebook for the unit2: Introduction to Q learning. While running the first command which install all the dependencies that are present in the requirements.txt file it fails because it is not able to install pickle5. I also tried installing that using the !pip install pickle5 but I am receiving the same error.

Error text: Collecting pickle5 Using cached pickle5-0.0.11.tar.gz (132 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: pickle5 error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. Building wheel for pickle5 (setup.py) ... error ERROR: Failed building wheel for pickle5 Running setup.py clean for pickle5 Failed to build pickle5 ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pickle5)

Notebook Link: https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit2/unit2.ipynb#scrollTo=udqxXq20EqeH

Material

  • Did you use Google Colab? Yes.

If not:

  • Your Operating system (OS)
  • Version of your OS

nikunjkakadiya2010 avatar Apr 09 '25 05:04 nikunjkakadiya2010

Hi, I confirm I'm also getting this error

C-Bone-UCL avatar Apr 09 '25 10:04 C-Bone-UCL

Hey, I have also come across this error, and it's easy to fix it up.

This is because the version of python the colab uses is 3.11, and pickle has been embedded in the python-3.11.

so what you have to do is :

  1. ignore the first line !pip install -r https://raw.githubusercontent.com/huggingface/deep-rl-class/main/notebooks/unit2/requirements-unit2.txt

  2. in the following import part, use

import numpy as np
import gymnasium as gym
import random
import imageio
import os
import tqdm

import pickle
from tqdm.notebook import tqdm

instead of

import numpy as np
import gymnasium as gym
import random
import imageio
import os
import tqdm

import pickle5 as pickle
from tqdm.notebook import tqdm

CumulusAlpha avatar Apr 10 '25 04:04 CumulusAlpha

You can also install dependecies without pickle5

!pip install gymnasium pygame numpy huggingface_hub pyyaml==6.0 imageio imageio_ffmpeg pyglet==1.5.1 tqdm

I just used import pickle and didn't bother to install pickle5 😅 Worked for me, easy fix.

Jason-XII avatar Aug 01 '25 02:08 Jason-XII

I also encountered this problem yesterday. pickle seems to be integrated into native CPython in Python 3.8 and above.

Zane-Liao avatar Sep 06 '25 10:09 Zane-Liao

You don't need pickle5! The functionality is built-in, If You're Using Python 3.8+.

mohammadkad avatar Sep 14 '25 06:09 mohammadkad