# Invoke Python script by activating virtual env from UiPath Studio X

**URL:** <https://forum.uipath.com/t/invoke-python-script-by-activating-virtual-env-from-uipath-studio-x/450802>\
**Category:** StudioX\
**Tags:** question, python, studiox, activities\
**Created:** [June 23, 2022, 2:00pm UTC](https://forum.uipath.com/t/invoke-python-script-by-activating-virtual-env-from-uipath-studio-x/450802 "2022-06-23T14:00:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apeksha123](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/apeksha123/32/59503_2.png) [@apeksha123](https://forum.uipath.com/u/apeksha123)\
**Post date:** [June 23, 2022, 2:00pm UTC](https://forum.uipath.com/t/invoke-python-script-by-activating-virtual-env-from-uipath-studio-x/450802/1 "2022-06-23T14:00:11Z")

</div>

I am working on a bot where I have to invoke a python script from StudioX and get the status if it completed successfully or not.  
Python Version 3.7.0  
Project Structure is as below:  
InvokePy  
|–\> main.xaml  
|–\>main.py  
|–\>venv

I have created a virtualenv ‘venv’ within which I have installed all the required python modules. I am trying to trigger main.py file from main.xaml file. The script works fine when i run the commands normally.

Solutions Attempted but not working:

1. I have tried using Python Scope activity with path ‘venv\Scripts’ instead of normal python path
2. I tried activating the venv within the main.py file. But when I do this I have to import all the required modules for each method I invoke from main
3. Tried using Command Prompt Activities and gave the commands to trigger py script. This worked for a day but since then when I trigger this even after the script has completed executing it doesnt terminate and UiPath becomes Unresponsive. Commands exceuted:

```auto
cd project_folder_path
venv\Scripts\activate
main.py

```

Is there anyway I can activate the venv and trigger py script from StudioX? Or trigger a .bat file?  
Any help is appreciated.

---

<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:** [June 25, 2022, 4:01pm UTC](https://forum.uipath.com/t/invoke-python-script-by-activating-virtual-env-from-uipath-studio-x/450802/2 "2022-06-25T16:01:40Z")

</div>

Hello @apeksha123!

It seems that you have trouble getting an answer to your question in the first 24 hours.  
Let us give you a few hints and helpful links.

First, make sure you browsed through our [**Forum FAQ Beginner’s Guide**](https://forum.uipath.com/t/forum-faq-beginner-s-guide/200562). It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

1. **Always search first**. It is the best way to quickly find your answer. Check out the [![image](https://global.discourse-cdn.com/uipath/original/3X/d/f/df7370d76626e03b84e2bf049481f5a20d345ef9.png)](https://forum.uipath.com/search) icon for that.  
Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

2. Topic that contains most common solutions with example project files can be found [**here**](https://forum.uipath.com/t/your-xaml-solutions-for-most-common-issues-wiki-post-anyone-can-edit/108894).

3. Read our [**official documentation**](https://docs.uipath.com) where you can find a lot of information and instructions about each of our products:

4. Watch the videos on our [**official YouTube channel**](https://www.youtube.com/user/UiPath) for more visual tutorials.

5. Meet us and our users on our [**Community Slack**](https://join.slack.com/t/uipathcommunity/shared_invite/zt-19ovcbo1u-S7xNszAzcJcdlG9o4A1CTA) and ask your question there.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly  
[Forum\_Staff](https://forum.uipath.com/new-message?groupname=Forum_Staff)

---

<div class="post-metadata">

**Author:** ![Afsal\_Baaqir\_A](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/afsal_baaqir_a/32/418644_2.png) [@Afsal\_Baaqir\_A](https://forum.uipath.com/u/Afsal_Baaqir_A)\
**Post date:** [August 8, 2023, 1:42pm UTC](https://forum.uipath.com/t/invoke-python-script-by-activating-virtual-env-from-uipath-studio-x/450802/3 "2023-08-08T13:42:43Z")

</div>

Hi, Have you tried executing simple Python scripts in StudioX, If so can you send that project file?  
I have tried on my own but, I don’t get any outputs also no errors too.
