I want to use Pickle in Google Colab

Asked 2 years ago, Updated 2 years ago, 136 views

As the title suggests, I would like to install and use Pickle on Google Colab.

Notable to pip install pickle in python 3.6-StackOverflow

Based on the above page, I ran the following command, but the pickle could not be installed (only the pickle-mixin could be installed).

!pip install pickle-mixin
! pip install pickle

After that,

import sys
import tensorflow as tf
import numpy as np
import matplotlib.pyplot asplt
import pickle

and

with open('***.data', 'rb') as file:
  images, labels=pickle.load(file)

If you run as shown in , you will get the following error:

ModuleNotFoundError: No module named 'numpy.core.multiarray\r'

How can I use the pickle?Thank you for your cooperation.

python python3 numpy google-colaboratory

2022-09-30 20:10

1 Answers

Notable to pip install pickle in python 3.6-StackOverflow
More

import sys
import numpy as np

src=sys.argv[1]# path to your file

data=open(src).read().replace('\r\n', '\n')#read and replace file contents
dst = src + ".tmp"
open(dst, "w").write(data)#save a temporary file

world=pickle.load(open(dst, "rb"), encoding='latin1')

Change and resolve the path as appropriate.


2022-09-30 20:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.