# Cannot Pickle Model Via Python Scope

**URL:** <https://forum.uipath.com/t/cannot-pickle-model-via-python-scope/342088>\
**Category:** Studio\
**Tags:** workflow-diff, question, studio, python, activities\
**Created:** [September 2, 2021, 1:24pm UTC](https://forum.uipath.com/t/cannot-pickle-model-via-python-scope/342088 "2021-09-02T13:24:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohaan\_Nadeem2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rohaan_nadeem2/32/179591_2.png) [@Rohaan\_Nadeem2](https://forum.uipath.com/u/Rohaan_Nadeem2)\
**Post date:** [September 2, 2021, 1:24pm UTC](https://forum.uipath.com/t/cannot-pickle-model-via-python-scope/342088/1 "2021-09-02T13:24:44Z")

</div>

I am trying to load this python file via a python scope but UiPath crashes with a ‘Pipe is Broken’ error.

Link to pickled model: [https://drive.google.com/file/d/1kdNLlXMdJatT-FKSR3Wb37P6yOGqolQf/view?usp=sharing](https://drive.google.com/file/d/1kdNLlXMdJatT-FKSR3Wb37P6yOGqolQf/view?usp=sharing)

Python Script:

```auto
import pickle
import numpy as np

def predict_label(x_test):
    filename = 'D:\\My POCs\\UiPath - Pickled Model\\pickled_model_2.pkl'

    loaded_model = pickle.load(open(filename, 'rb'))
    file1 = open("D:\\My POCs\\UiPath - Pickled Model\\Model_pickling\\myfile.txt","w")
    file1.write(x_test)
    file1.write('\n')
    file1.close()

```

I know I have chosen the right activities because this script works when I comment out the pickle.load command.

Thanks

---

<div class="post-metadata">

**Author:** ![loginerror](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/loginerror/32/22614_2.png) [@loginerror](https://forum.uipath.com/u/loginerror)\
**Post date:** [September 2, 2021, 5:50pm UTC](https://forum.uipath.com/t/cannot-pickle-model-via-python-scope/342088/2 "2021-09-02T17:50:36Z")

</div>

Hi @Rohaan_Nadeem2

I am not sure if that will solve your issue, but maybe you could have a look at this simple post:

> [@Load Python Script: One or more errors occurred](https://forum.uipath.com/t/load-python-script-one-or-more-errors-occurred/264497/23):
>
> A bit of extra info here. The Python activities are invoked regardless of context, using only the Windows environment variables. If, for some reason, a certain path is not set or if a certain Python package is only available in a certain environment (e.g. in the Miniconda console you used to install a certain version of Python), then the script execution will fail. As a simple verification, you should be able to run the script using nothing but the Windows Command Prompt. \<path to python.exe\> …

---

<div class="post-metadata">

**Author:** ![Rohaan\_Nadeem2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rohaan_nadeem2/32/179591_2.png) [@Rohaan\_Nadeem2](https://forum.uipath.com/u/Rohaan_Nadeem2)\
**Post date:** [September 6, 2021, 9:17am UTC](https://forum.uipath.com/t/cannot-pickle-model-via-python-scope/342088/3 "2021-09-06T09:17:08Z")

</div>

Hey @loginerror

This was the a brilliant suggestion. I ran the script on CMD and realized the base environment was missing 1 library. Once I installed it, the program has been running flawlessly.

Thanks!!
