从python3.9升级到了3.11,但项目之前安装的软件包找不到了,报错:
"C:\Program Files\Python311\python.exe" C:\Users\Hello\PycharmProjects\xx_ui_auto\test_regression.py
Traceback (most recent call last):
File "C:\Users\Hello\PycharmProjects\xx_ui_auto\test_regression.py", line 13, in <module>
from appium import webdriver
File "C:\Users\Hello\AppData\Roaming\Python\Python311\site-packages\appium\webdriver\__init__.py", line 19, in <module>
from .webdriver import WebDriver as Remote
File "C:\Users\Hello\AppData\Roaming\Python\Python311\site-packages\appium\webdriver\webdriver.py", line 32, in <module>
from appium.options.common.base import AppiumOptions
File "C:\Users\Hello\AppData\Roaming\Python\Python311\site-packages\appium\options\common\__init__.py", line 1, in <module>
from .base import AppiumOptions
File "C:\Users\Hello\AppData\Roaming\Python\Python311\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'
进程已结束,退出代码1
解决方法:
重新创建虚拟环境,并指定解释器,重新创建虚拟环境后pycharm会自动把python可执行文件复制到venv目录下,该目录下包含Lib和Sripts目录,之后重新下载软件包。
其他:
我们在安装appium本地环境时,分为以下两部分:
一、appium 端,包含一系列插件、驱动、相关环境,通过npm安装;
二、安装appium相关的python软件包,例如,appium-python-client、appium-UIAutomation,这一步又分为两种情况,第一种情况是通过pycharm安装(设置->解释器窗口)、第二种情况是在本地通过python环境安装(pip),两者安装软件报的位置不同,前者是在venv->Lib->site-packages,后者安装在了这个目录下:C:\Users\Hello\AppData\Roaming\Python\Python311\site-packages