# Python : Pipe is broken

**URL:** <https://forum.uipath.com/t/python-pipe-is-broken/416962>\
**Category:** RPA Discussions\
**Tags:** coding, general, security\
**Created:** [April 21, 2022, 1:10pm UTC](https://forum.uipath.com/t/python-pipe-is-broken/416962 "2022-04-21T13:10:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hari\_Balaji](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hari_balaji/32/297703_2.png) [@Hari\_Balaji](https://forum.uipath.com/u/Hari_Balaji)\
**Post date:** [April 21, 2022, 1:10pm UTC](https://forum.uipath.com/t/python-pipe-is-broken/416962/1 "2022-04-21T13:10:44Z")

</div>

Hi,  
I’m working on invoking the python script in my project to decrypt the encrypt and decrypt the password using the AWS KMS service. I have created the python code and tested it locally which works fine while running through the python IDE.

when I tried to “Invoke python method” I’m getting a pipe is a broken error on the UI path.  
Could someone please provide some feedback/suggestions on this?

Appreciate your help. Let me know if you need more details.

_ **Python Code** _

```auto
import base64
import boto3

def encrypt(secret):
    session = boto3.session.Session()

    key_id = 'alias/xxxx'
    client = session.client('kms',
                            region_name='us-east-1',
                            aws_access_key_id="xxxxx",
                            aws_secret_access_key="xxxxx"
                            )
    ciphertext = client.encrypt(
        KeyId=key_id,
        Plaintext=bytes(secret, 'utf-8'),
    )
    return base64.b64encode(ciphertext["CiphertextBlob"])

```

 ![pythonscope](https://global.discourse-cdn.com/uipath/original/4X/2/2/1/221e93c62b51466aae8d40e5297fb7ee0d76c436.png)

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 21, 2022, 1:16pm UTC](https://forum.uipath.com/t/python-pipe-is-broken/416962/2 "2022-04-21T13:16:25Z")

</div>

@Hari_Balaji,

Try placing the import Statements inside the function and Check.

Could you also specify the Working Folder i.e the Current Directory Folder and Check.

---

<div class="post-metadata">

**Author:** ![Hari\_Balaji](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hari_balaji/32/297703_2.png) [@Hari\_Balaji](https://forum.uipath.com/u/Hari_Balaji)\
**Post date:** [April 21, 2022, 1:32pm UTC](https://forum.uipath.com/t/python-pipe-is-broken/416962/3 "2022-04-21T13:32:20Z")

</div>

Hello @supermanPunch ,

Thanks, I have replaced the import inside the def function itself and added a working directory still getting the same error. When I tried to run the code on windows cmd it worked.

Is there any other possibility…?

```auto
def encrypt(secret):
    import base64
    import boto3
    session = boto3.session.Session()
    key_id = 'alias/xxxx'
    client = session.client('kms',
                            region_name='us-east-1',
                            aws_access_key_id="xxxxx",
                            aws_secret_access_key="xxxxx"
                            )
    ciphertext = client.encrypt(
        KeyId=key_id,
        Plaintext=bytes(secret, 'utf-8'),
    )
    return base64.b64encode(ciphertext["CiphertextBlob"])

```

 ![Screenshot_1](https://global.discourse-cdn.com/uipath/original/4X/5/d/3/5d3cac61ee7474a000a6dfde0fe24bfe5197b181.png)

---

<div class="post-metadata">

**Author:** ![Hari\_Balaji](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hari_balaji/32/297703_2.png) [@Hari\_Balaji](https://forum.uipath.com/u/Hari_Balaji)\
**Post date:** [April 23, 2022, 6:14am UTC](https://forum.uipath.com/t/python-pipe-is-broken/416962/4 "2022-04-23T06:14:57Z")

</div>

Hello,  
I have figured out the issues and fixed them.  
The actual issue was I have two python versions installed on the windows machine which cause the trouble. When is initialize the bot it takes the default python and pip environment while invoking the python process.

What I did was add the python path on the system environment variable to the local machine so that it will alias to the required version and also added the pip environment folder into the system environment variable.

To get the python path open cmd and run below cmd.

> where python

To check the pip run the below cmd

> pip --help

Once we add it double-check the python path on the UI path and the function used to invoke it.

That solved my issues. I hope this might help others. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [April 26, 2022, 6:15am UTC](https://forum.uipath.com/t/python-pipe-is-broken/416962/5 "2022-04-26T06:15:45Z")

</div>

Closed on April 26, 2022, 6:15am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
