python - 每次使用 Python 打开和执行新项目时,我们是否需要安装 Selenium?
问题描述
我在 python 项目中安装了 selenium 和 chrome 驱动程序,当我创建一个新项目时说它无法识别 selenium 模块。
这是否意味着每个项目我都需要再次安装 selenium?
解决方案
不,您不需要为每个项目安装Selenium。安装过程一生中只有一次,通过命令行界面使用以下命令之一:
使用点子:
pip install selenium
使用pip3:
pip3 install selenium
升级点
但是,您需要继续定期升级 pip :
-
pip install -U pip
在窗户上:
python -m pip install -U pip
或者
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
升级硒
作为一项强制性措施,您需要升级Selenium绑定以与每个稳定版本的发布保持同步,如下所示:
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.
参考
您可以在以下位置找到详细的相关讨论:
推荐阅读
- c# - Xamarin ios 自定义 WKWebview 渲染器默认解析 youtube 视频全屏显示
- python - 使用 Google 进行阿拉伯情绪分析
- javascript - 快速会话空会话
- html - 如何删除摘要元素侧面的箭头?
- cuda - CUDA 内核失败:没有可在设备上执行的内核映像,在 Google Compute VM 中运行 PyTorch 模型时出错
- websocket - 是否可以将 websocket 消息发送到 kafka 主题?
- amazon-web-services - 无法访问使用现有实例的映像创建的 AWS 实例
- java - JSch 没有检测到 $HOME/.ssh/id_rsa 公钥
- angular - 如何在 ionic 4 中使用 ion-range 调整所有页面的字体大小?
- latex - 更改乳胶中的引用语言