0

I have selenium installed and chrome driver in a python project, when i create a new project is says it can't recognize the selenium module.

Does this mean with each project I'll need to install selenium again?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

4 Answers4

1

No, you don't need to install Selenium for each project. The installation procedure is only once in a lifetime using either of the following commands through command line interface:

  • Using pip:

    pip install selenium
    
  • Using pip3:

    pip3 install selenium
    

Upgrading pip

However, you would need to keep on upgrading pip periodically:

  • On or :

    pip install -U pip
    
  • On :

    python -m pip install -U pip
    
  • Or

    C:\Users\username>python -m pip install --upgrade pip
    Collecting pip
      Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
      100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 1.3MB 544kB/s
    Installing collected packages: pip
      Found existing installation: pip 10.0.1
        Uninstalling pip-10.0.1:
          Successfully uninstalled pip-10.0.1
    Successfully installed pip-18.0
    

Upgrading Selenium

As a mandatory measure you need to upgrade the Selenium bindings to keep in sync with the release of each stable version as follows:

C:\Users\username>pip install -U selenium
Collecting selenium
  Downloading https://files.pythonhosted.org/packages/b8/53/9cafbb616d20c7624ff31bcabd82e5cc9823206267664e68aa8acdde4629/selenium-3.14.0-py2.py3-none-any.whl (898kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 901kB 380kB/s
Requirement not upgraded as not directly required: urllib3 in c:\python\lib\site-packages (from selenium) (1.22)
Installing collected packages: selenium
  Found existing installation: selenium 3.12.0
    Uninstalling selenium-3.12.0:
      Successfully uninstalled selenium-3.12.0
Successfully installed selenium-3.14.0
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Reference

You can find a detailed relevant discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

You need to initialize browser in selenium each time when you are trying to run your automation test.

driver = webdriver.Chrome('./chromedriver')
driver.get("https://www.python.org")
print(driver.title)

You dont need to install selenium everytime you just need to initialize browser session wwhen you are trying to run your test from differnt project.

Also use pip to install the selenium package.

Try below command to install selenium using pip command after installing python

pip install selenium

You will find your dependancies under Python\Lib\site-packages

enter image description here

SeleniumUser
  • 4,065
  • 2
  • 7
  • 30
0

You don't need every time , you need use by giving path and locate to folder in your machine

Justin Lambert
  • 940
  • 1
  • 7
  • 13
0

yes you need to. In cases where you create virtual environment for each projects. It is better to have it install into the project virtual environment. This will save you a lot of stress debugging your code later in future.

lvingstone
  • 171
  • 8