# Using "load\_metric" offline in datasets

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-load-metric-offline-in-datasets%2F9283%3E%5C
**Category:** 🤗Datasets\
**Created:** [August 17, 2021, 1:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-load-metric-offline-in-datasets%2F9283 "2021-08-17T01:37:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeril](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeril](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjeril)%5C
**Post date:** [August 17, 2021, 1:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-load-metric-offline-in-datasets%2F9283%2F1 "2021-08-17T01:37:18Z")

</div>

My office PC doesn’t have access to internet, and the `load_metric` function downloads the metric from internet. I tried pickling using the following code:

`PC 1 (connected to internet)`

```auto
import pickle
from datasets import load_metric
metric = load_metric("glue", "mrpc")
with open('metric.pickle', 'wb') as handle:
    pickle.dump(metric, handle, protocol=pickle.HIGHEST_PROTOCOL)

```

Now i copied the metric pickle file to the offline PC, and tried opening using the followng code:

```auto
import pickle
with open('metric.pickle', 'rb') as handle:
    metric = pickle.load(handle)

```

but it gived the following error:

```auto
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
ModuleNotFoundError: No module named 'datasets_modules'

```

Is there way to use datasets `load_metric` in offline mode?  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/52888_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [August 23, 2021, 4:04pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-load-metric-offline-in-datasets%2F9283%2F2 "2021-08-23T16:04:21Z")

</div>

Hi ! Yes you just need to have the metric python file from [datasets/metrics at master · huggingface/datasets · GitHub](https://github.com/huggingface/datasets/tree/master/metrics) and load it with

```python
load_metric("path/to/metric.py")

```

---

<div class="post-metadata">

**Author:** ![jeril](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeril](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjeril)%5C
**Post date:** [August 24, 2021, 7:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-load-metric-offline-in-datasets%2F9283%2F3 "2021-08-24T07:28:32Z")

</div>

Thank you so much, it worked.
