# Python Virtual Environment

**URL:** <https://forum.uipath.com/t/python-virtual-environment/400025>\
**Category:** Studio\
**Tags:** new-feature-request, virtual-environment, question, studio, python, activities\
**Created:** [Février 17, 2022, 6:59 UTC](https://forum.uipath.com/t/python-virtual-environment/400025 "2022-02-17T06:59:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jeevith](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jeevith/32/288449_2.png) [@jeevith](https://forum.uipath.com/u/jeevith)\
**Post date:** [Février 18, 2022, 8:04 UTC](https://forum.uipath.com/t/python-virtual-environment/400025/2 "2022-02-18T20:04:16Z")

</div>

Hi @Donnas,

I agree that this could be really good to support out of the box. However, if you want to run the python scope from a python installed in a shared drive/VM / USB stick you can look at this workaround here :

Via a shared drive : [Python integration with different vm's - #7 by jeevith](https://forum.uipath.com/t/python-integration-with-different-vms/386337/7)

Via a USB : [How to run python script in UiPath without installing python? - #4 by jeevith](https://forum.uipath.com/t/how-to-run-python-script-in-uipath-without-installing-python/271827/4)

The point being, UiPath’s invoke python scope does not care where python is installed but it wants to see a full installation python in the folder path provided in the activity.

Since the folder structure of a virtual env is not similar to a standard install of python, it fails. If you use the python.exe from “env/Scripts/” (as the python installation folder being parsed by UiPath does not support the virtualenv folder structure).

For people who are wondering what the error message we get:  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/5/a/55afec579b065e2e84ee814797a28790e44246c4.png)

**In this case there is an alternative:**

Another approach is to skip Python Scope activity and rather use ever versatile Invoke PowerShell activity.

1. cd to your working folder path where you have the virtual environment
2. Activate the virtualenv from PowerShell
3. Run python “pythonfile.py”
4. In the Invoke PowerShell activity, return the output as PSOutput (as the datatype required)

 ![image](https://global.discourse-cdn.com/uipath/original/4X/0/3/4/034ca39efcfe87a79416408a09fc98bc35cfad85.png)

**Resources**

```auto
Param(
[Parameter(Mandatory=$true)] [string]$VirtualEnvFolder,
[Parameter(Mandatory=$true)] [string]$PythonFilePath
)
cd $VirtualEnvFolder
env/Scripts/activate.bat
python $PythonFilePath

```

```auto
def runInVirtualEnv():
    return "I just ran on a virtual env!"

print (runInVirtualEnv())

```

[PythonVirtualEnv.xaml](https://forum.uipath.com/uploads/short-url/78XZCyhebgqlR4C2W7v291TEZ2Y.xaml) (8.8 KB)

**Why not use the default activate.ps1 to activate?**  
I use the default `.bat` file to activate the virtualenv. You can use `activate.ps1` if you wish, but in my experience `.ps1` scripts usually require higher user access with a set execution policy `Set-ExecutionPolicy Unrestricted` . It is done for security, but when activating virtualenv `.bat` file will work without errors.

Hope this helps you and others.

---

_[View the full topic](https://forum.uipath.com/t/python-virtual-environment/400025)._
