How to install Appium with selenium 3 (not 4) in Python?

Python 3.10

I am making a script with Appium and Selenium.

TouchAction and ActionChains are deprecated in Selenium 4. So I had to downgrade Selenium to version 3.
But then I get this error when I run my script :

Traceback (most recent call last):
  File "C:\Users\gauth\Documents\Projet\Projet_debug3\Projet.py", line 347, in <module>
    from modules import prepare_envir_appium
  File "C:\Users\gauth\Documents\Projet\Projet_debug3\modules\prepare_envir_appium.py", line 24, in <module>
    import modules.mymodulesteam as mymodulesteam
  File "C:\Users\gauth\Documents\Projet\Projet_debug3\modules\mymodulesteam.py", line 31, in <module>
    import appium.webdriver.common.touch_action
  File "C:\Users\gauth\AppData\Local\Programs\Python\Python310\lib\site-packages\appium\webdriver\__init__.py", line 19, in <module>
    from .webdriver import WebDriver as Remote
  File "C:\Users\gauth\AppData\Local\Programs\Python\Python310\lib\site-packages\appium\webdriver\webdriver.py", line 26, in <module>
    from appium.options.common.base import AppiumOptions
  File "C:\Users\gauth\AppData\Local\Programs\Python\Python310\lib\site-packages\appium\options\common\__init__.py", line 1, in <module>
    from .base import AppiumOptions
  File "C:\Users\gauth\AppData\Local\Programs\Python\Python310\lib\site-packages\appium\options\common\base.py", line 21, in <module>
    from selenium.webdriver.common.options import BaseOptions
ModuleNotFoundError: No module named 'selenium.webdriver.common.options'

The line 31 in my script “C:\Users\gauth\Documents\Projet\Projet_debug3\modules\mymodulesteam.py” is :

from appium.webdriver.common.touch_action import TouchAction

So I had the idea to uninstall Appium and reinstall it in order to make work packages of both Appium and Selenium 3.

But when I install Appium with:

python -m pip install Appium-Python-Client

It uninstalled Selenium 3 and install Selenium 4. So my question is “How can I install Appium with Selenium 3”. How can I fix this issue and make work my script again?

You have installed a python library that contains python files necessary for everything to work, because in this case you would have to look for one of the python files related to this library that is installing selenium 4. I believe it is this file:

Try looking for that same file somewhere in your operating system (I don’t know what system you are using) and change the line in the file that contains “selenium-4” to selenium 3. If it’s not this file, look for the file in this github repository until you find it later search your system and make the necessary change.

1 Like