gpt4 book ai didi

python - 如何使用 python3 安装 selenium?

转载 作者:行者123 更新时间:2023-12-04 19:14:05 24 4
gpt4 key购买 nike

解压 .tar.gz 并运行 python setup install 后, Selenium 被安装在,

....
creating /usr/local/lib/python2.7/dist-packages/selenium-3.4.3-py2.7.egg
Extracting selenium-3.4.3-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding selenium 3.4.3 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/selenium-3.4.3-py2.7.egg
.....

运行时,
python functionalTest.py 

它工作正常


python3.6 functionalTest.py

给出,错误:
ModuleNotFoundError: No module named 'selenium'

因为我无法在Ubuntu上使用python3.6安装selenium,成功,如下图,
$ ls setup*
setup.cfg setup.py
$ python3.6 setup install
python3.6: can't open file 'setup': [Errno 2] No such file or directory
$ python3.6 setup.py install
Traceback (most recent call last):
File "setup.py", line 22, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
.....
Original exception was:
Traceback (most recent call last):
File "setup.py", line 22, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
$

编辑:

安装 setuptools 后,以下是观察结果,
$ python3.6 setup.py install
.....
creating /usr/local/lib/python2.7/dist-packages/selenium-3.4.3-py2.7.egg
Extracting selenium-3.4.3-py2.7.egg to /usr/local/lib/python2.7/dist-packages
selenium 3.4.3 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.7/dist-packages/selenium-3.4.3-py2.7.egg
Processing dependencies for selenium==3.4.3
Finished processing dependencies for selenium==3.4.3
$ cd /usr/local/lib/python
python2.7/ python3.5/ python3.6/
$
$ easy_install --version
setuptools 20.7.0 from /usr/lib/python2.7/dist-packages (Python 2.7)
$ pip --version
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$

问题:

python3.6如何配置选择selenium?为什么 Selenium 安装在 /usr/local/lib/python2.7尽管使用了 python3.6 ?

最佳答案

看起来您安装了多个版本的 Python。根据您提供的日志,您似乎已将 Selenium 安装到 Python 2.7 安装中。

如果您已将 Python 3 更改为使用命令“python3.6”在您的 cmd 中运行,那么您应该执行以下操作来运行设置:

python3.6 setup install

关于python - 如何使用 python3 安装 selenium?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44854635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com