I have a script that imports Selenium WebDriver and it runs fine in VisualStudio debugger but fails when I call it from an Excel module because it can't find the Selenium module. Here's the code stub:

from bs4 import BeautifulSoup
import sys
import csv
from selenium import webdriver

If I comment out the selenium import line it runs when I call it from Excel.

I assume these are running in different environments.

I installed Selenium via pip in a terminal window which made it available to the debugger but not to whatever runs when I call it from Excel.

Any ideas about how to check and fix this?

  • Hi Phil. To avoid down votes, consider editing this so only one question is asked per question. Hopefully this and your other question get you some traction
    – bmike
    Commented Dec 18, 2023 at 17:40
  • Thanks Mike. I'm new at this. I appreciate the suggestion.
    – Phil
    Commented Dec 18, 2023 at 18:27
  • Being new is a womderful place from which to learn. Excellent clarity now IMO. No excel for me, but I’ll post an answer if I can dig something up that might help get started on an answer.
    – bmike
    Commented Dec 18, 2023 at 18:32
  • Does Excel package a python interpreter? What python are you installing Selenium in? Commented Dec 18, 2023 at 22:35
  • Python 3.10.9. No, Excel has no direct way to invoke a Python script that I'm aware of on the Mac. I have to run it indirectly by using AppleScriptTask to indirectly invoke it. It is a bit of a kludgy way to get the job done but a few generations ago, Microsoft dropped support for running Internet Explorer directly from VBA so this was the best solution I could come up with. I have used Python scripts to call APIs with no problem it is only when I try to import the Selenium modules that I have an issue. Beautiful soup was no problem.
    – Phil
    Commented Dec 18, 2023 at 22:45


You must log in to answer this question.

Browse other questions tagged .