python(selenium)mac没有找到模块

时间:2018-11-17 22:21:50

标签: python macos selenium selenium-webdriver pip

所以我一直试图在终端上使用pip3在macbook pro 2015上将硒下载到python(上面说我下载了):

Arons-mbp:~ Aron$ pip3 install selenium
Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages (3.141.0)
Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages (from selenium) (1.24.1)

但是,当我想在python上运行程序时,我是在另一台计算机上编写的(windows:但是我更改了代码使其可以在mac上运行)(它只是一个基本的测试程序,可以自动单击网络游戏):

#!/usr/bin/python3
from selenium import webdriver
import time

driver = webdriver.Chrome('/usr/local/bin')
driver.get('http://orteil.dashnet.org/cookieclicker/')
time.sleep(5)
cookie = driver.find_element_by_xpath('//*[@id="bigCookie"]')
while 1 != 0:
cookie.click()

我回来了:

Traceback (most recent call last):
    File "/Users/Aron/Documents/cookieclicker.py", line 1, in <module>
        from selenium import webdriver
    File "/Users/Aron/Documents/selenium.py", line 1, in <module>
        from selenium.webdriver import chromedriver
ModuleNotFoundError: No module named 'selenium.webdriver'; 'selenium' is not a package

我在互联网上进行了搜索,但似乎找不到解决方法 谢谢:)

编辑:使用sudo pip3安装selenium我得到:

Arons-mbp:~ Aron$ sudo pip3 install selenium
Password:
The directory '/Users/Aron/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/Aron/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (3.141.0)
Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from selenium) (1.24.1)

使用sudo -H pip3安装我得到的硒:

Arons-mbp:~ Aron$ sudo -H pip3 install selenium
Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (3.141.0)
Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from selenium) (1.24.1)

运行程序后,我仍然会遇到相同的错误。

当我跑步时:

192:~ Aron$ pip list
Package    Version
---------- -------
pip        18.1   
selenium   3.141.0

所以我确实安装了它

edit:所以我走得更远,我查找了硒包所在的位置,并将其复制到我的文件旁边,但是后来找不到urllib3,所以我做了同样的事情,现在当我运行它时,我遇到了两个不同的错误:

Traceback (most recent call last):
    File "/Users/bleieraron/Documents/selenium/webdriver/common/service.py", line 76, in start
        stdin=PIPE)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 769, in __init__
        restore_signals, start_new_session)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1516, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
    File "/Users/bleieraron/Documents/cookieclicker.py", line 7, in <module>
        driver = webdriver.Chrome('/usr/local/bin')
    File "/Users/bleieraron/Documents/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
        self.service.start()
    File "/Users/bleieraron/Documents/selenium/webdriver/common/service.py", line 88, in start
        os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'bin' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

0 个答案:

没有答案