Selenium“即使在安装pip3之后,也没有名为“ selenium”的模块”

时间:2020-02-19 11:17:51

标签: python selenium

即使安装了pip后,我仍然不知道为什么import selenium仍然无法运行。 有人知道我还有什么办法可以解决或解决此问题吗?

我正在使用Mac OS和python 3.7.4

python3                                                  
Python 3.7.4 

Type "help", "copyright", "credits" or "license" for more information.
>>> import selenium
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'selenium'
>>>
pip3 install selenium                                                                          
Requirement already satisfied: selenium in /usr/local/lib/python3.7/site-packages
Requirement already satisfied: urllib3 in /usr/local/lib/python3.7/site-packages (from selenium) 

更新

我有点无所适从,而我所做的其中一件事情就是使它工作。我不确定哪个项目可以使用,但是如果有人可以解释,那么将来我会理解,将不胜感激。

  1. 我做了brew doctor,它输出了以下内容
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or
https://developer.apple.com/download/more/.


Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python
  1. brew link --overwrite python
  2. vi /usr/local/bin/pip 并将/usr/local/opt/python/bin/python3.7更改为/usr/local/opt/python/bin/python3,就可以了 我猜我的问题是我安装了两个python实例,因此它正在将硒库下载到另一个python版本(3.7)而不是我想要的3。

让我知道您是否认为这是问题所在,或者是否可以澄清您可能认为的问题

2 个答案:

答案 0 :(得分:0)

请使用命令检查点子版本

pip --version

通常,pip与python 2.7版本相关,而pip3与python3相关。

所以,尝试-

pip3 install selenium 

由于pip将为python2安装它,而pip3将为python3安装,因为您在问题中使用的是python3。

答案 1 :(得分:0)

尝试安装pip,而不是pip3