# Python Scope Issue: Runtime Error when running python script with selenium library imported

**URL:** <https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453>\
**Category:** Studio\
**Tags:** awaiting-user-response, bug, activities-panel, studio, python, activities\
**Created:** [May 29, 2024, 10:02pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453 "2024-05-29T22:02:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 29, 2024, 10:02pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/1 "2024-05-29T22:02:40Z")

</div>

Hi community,  
I’m trying to run a python script to webscrape, and I’m using the Selenium library, but I’m getting a particular error message that says “cannot import name ‘webdriver’ from ‘selenium’”  
Below is a more comprehensive version of the error message.  
NOTE: I copied this error from my PC’s Event Viewer window.

`Application: UiPath.Python.Host.exe CoreCLR Version: 6.0.3024.21525 .NET Version: 6.0.30 Description: The process was terminated due to an unhandled exception. Exception Info: Python.Runtime.PythonException: ImportError : cannot import name 'webdriver' from 'selenium' (C:\Python\Python37\lib\site-packages\selenium\ __init__.py) [' File "none", line 4, in goto_github_and_download_file\n'] at Python.Runtime.PyObject.Invoke(PyObject[] args) at Python.Runtime.PyObject.InvokeMethod(String name, PyObject[] args) `  
However, the other python methods without the selenium dependency work perfectly. The error is just peculiar to the method that uses the selenium library.

Your help will be greatly appreciated in fixing this issue. I’m available to provide further details if required.

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [May 30, 2024, 4:00am UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/3 "2024-05-30T04:00:19Z")

</div>

@Babatunde_Omotayo

Few things here

1. Only this import is not working or any import is not working?
2. Did you happen to provide the library path?
3. And is the target package installed in same instance of python which is invoked from UiPath?

Cheers

---

<div class="post-metadata">

**Author:** ![ByteBreaker](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/bytebreaker/32/410625_2.png) [@ByteBreaker](https://forum.uipath.com/u/ByteBreaker)\
**Post date:** [May 30, 2024, 4:05am UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/4 "2024-05-30T04:05:36Z")

</div>

What do you get when pip show selenium?

---

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 30, 2024, 8:59am UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/5 "2024-05-30T08:59:38Z")

</div>

Thank you for your response

1. Yeah, only the selenium import is not working. All other imports work perfectly
2. Yeah, I provided the path the correct python path
3. And yes the package is installed in the same python instance that is invoked into UiPath

Below is a description of the selenium package installed and the path  
C:\Python\Python37\>C:\Python\Python37\python.exe -m pip show selenium  
Name: selenium  
Version: 4.11.2  
Summary: None  
Home-page: [https://www.selenium.dev](https://www.selenium.dev)  
Author: None  
Author-email: None  
License: Apache 2.0  
Location: c:\python\python37\lib\site-packages  
Requires: trio-websocket, trio, certifi, urllib3  
Required-by:

Below is a screenshot of where I defined the python path in my workflow  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/5/4/7545a44531a61f84f509b05c416aa797b012afb3.png)

Thank you…I look forward to your response

---

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 30, 2024, 9:02am UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/6 "2024-05-30T09:02:27Z")

</div>

![image](https://global.discourse-cdn.com/uipath/original/4X/b/f/b/bfb5ea7596e8888b642b84f10c52ca1fa1460558.png)  
This is what i get

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [May 30, 2024, 12:44pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/7 "2024-05-30T12:44:28Z")

</div>

@Babatunde_Omotayo

Try giving the lib path as well in the python field

Cheers

---

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 30, 2024, 1:38pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/8 "2024-05-30T13:38:23Z")

</div>

I hope this is what you mean  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/1/8/a1855a5a457c49e8492ee0c94ba81bb1039ff036.png)

Also, below is the breakkdown of the folder structure

- Python
  - Python37
    - Lib
      - site\_packages
        - selenium
          - webdriver
            - common
            - chrome
              - webdriver.py

            - edge
              - webdriver.py

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [May 30, 2024, 1:39pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/9 "2024-05-30T13:39:32Z")

</div>

@Babatunde_Omotayo

I meant give the python library path in the python scope library path argument

cheers

---

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 30, 2024, 1:44pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/10 "2024-05-30T13:44:23Z")

</div>

Okay, I did that already

 ![image](https://global.discourse-cdn.com/uipath/original/4X/9/9/3/993109a31796506d88b97e8d75e78293975d7053.png)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [May 30, 2024, 1:48pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/11 "2024-05-30T13:48:11Z")

</div>

@Babatunde_Omotayo

the field above it library path…give the lib folder path

cheers

---

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 30, 2024, 2:03pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/12 "2024-05-30T14:03:44Z")

</div>

Okay…Like it is shown below right?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/f/6/3f6a98bfa74a24c563073eee9bc432da2f51c08e.png)

---

<div class="post-metadata">

**Author:** ![Babatunde\_Omotayo](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Babatunde\_Omotayo](https://forum.uipath.com/u/Babatunde_Omotayo)\
**Post date:** [May 30, 2024, 4:48pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/13 "2024-05-30T16:48:58Z")

</div>

Hello @Anil_G  
Just checking in please.  
I’ve implemented your solution but still getting the same error

I look forward to your response.  
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:** [November 8, 2024, 2:00pm UTC](https://forum.uipath.com/t/python-scope-issue-runtime-error-when-running-python-script-with-selenium-library-imported/744453/15 "2024-11-08T14:00:48Z")

</div>

First things first - the library path should be provided as per this documentation example:

> **[Activities - Invoking a Python Script](https://docs.uipath.com/activities/other/latest/developer/invoking-a-python-script)**
>
> The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...

Apart from that, I tested it just now with Python 3.12 and it makes this import correctly:

 ![image](https://global.discourse-cdn.com/uipath/original/4X/4/b/9/4b95e3146d76d5ab1735b213754c4f28ef9f0186.png)

And therefore we would need more info:

- first, whether this script works for you:

```auto
from selenium import webdriver
def dummy_func():
    return "text"

```
