所以我一直坚持这个问题大约一个星期。意外删除了我需要的virtualenv并设置了一个新的,我在代码中也经历了一次小的重构。
我们一直在使用Selenium做一些webscraping,一切都在我们的开发环境中运行良好。这是我们用于Selenium的代码:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
browser = webdriver.PhantomJS("selenium/phantomjs.exe")
browsers[url] = browser
browser.get(url)
我得到的主要错误是:
2017-01-20 16:32:35,910 :[2017-01-20 16:32:35,908] ERROR in app: Exception on /processCart [GET]
2017-01-20 16:32:35,910 :Traceback (most recent call last):
2017-01-20 16:32:35,910 : File "/home/murtazabambot/.virtualenvs/my-virtualenv/lib/python3.4/site-packages/selenium/webdriver/common/service.py", line 74, in start
2017-01-20 16:32:35,910 : stdout=self.log_file, stderr=self.log_file)
2017-01-20 16:32:35,910 : File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
2017-01-20 16:32:35,910 : restore_signals, start_new_session)
2017-01-20 16:32:35,910 : File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
2017-01-20 16:32:35,910 : raise child_exception_type(errno_num, err_msg)
2017-01-20 16:32:35,911 :PermissionError: [Errno 13] Permission denied
2017-01-20 16:32:35,911 :
2017-01-20 16:32:35,911 :During handling of the above exception, another exception occurred:
2017-01-20 16:32:35,911 :
2017-01-20 16:32:35,911 :Traceback (most recent call last):
2017-01-20 16:32:35,911 : File "/home/murtazabambot/.virtualenvs/my-virtualenv/lib/python3.4/site-packages/flask/app.py", line 1612, in full_dispatch_request
2017-01-20 16:32:35,911 : rv = self.dispatch_request()
2017-01-20 16:32:35,911 : File "/home/murtazabambot/.virtualenvs/my-virtualenv/lib/python3.4/site-packages/flask/app.py", line 1598, in dispatch_request
2017-01-20 16:32:35,911 : return self.view_functions[rule.endpoint](**req.view_args)
2017-01-20 16:32:35,911 : File "/home/murtazabambot/InternBlitz/routes/cart.py", line 60, in processCart
2017-01-20 16:32:35,911 : return findMissingInfo(session['cart'])
2017-01-20 16:32:35,911 : File "/home/murtazabambot/InternBlitz/routes/cart.py", line 162, in findMissingInfo
2017-01-20 16:32:35,911 : missingInfo, closed = applicationHandler.findAllMissingInfo(urls, ids, platforms, session)
2017-01-20 16:32:35,911 : File "/home/murtazabambot/InternBlitz/applicationHandler.py", line 17, in findAllMissingInfo
2017-01-20 16:32:35,912 : missingInfo.append(greenhouseScripts.findMissingInfo(url))
2017-01-20 16:32:35,912 : File "/home/murtazabambot/InternBlitz/greenhouseScripts.py", line 57, in findMissingInfo
2017-01-20 16:32:35,912 : allInfo = findAllInfo(url)
2017-01-20 16:32:35,912 : File "/home/murtazabambot/InternBlitz/greenhouseScripts.py", line 72, in findAllInfo
2017-01-20 16:32:35,912 : browser = webdriver.PhantomJS("selenium/phantomjs.exe")
2017-01-20 16:32:35,912 : File "/home/murtazabambot/.virtualenvs/my-virtualenv/lib/python3.4/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
2017-01-20 16:32:35,912 : self.service.start()
2017-01-20 16:32:35,912 : File "/home/murtazabambot/.virtualenvs/my-virtualenv/lib/python3.4/site-packages/selenium/webdriver/common/service.py", line 86, in start
2017-01-20 16:32:35,912 : os.path.basename(self.path), self.start_error_message)
2017-01-20 16:32:35,912 :selenium.common.exceptions.WebDriverException: Message: 'phantomjs.exe' executable may have wrong permissions.
我已经尝试使用“chmod -R 777 chromedriver”修复程序让它运行起来,但后来我得到以下错误:
[Errno 8] Exec format error
关于所有这一切最烦人的部分是它在一周前完全正常工作,但现在一切似乎已经破碎。所以我知道它肯定适用于PythonAnywhere,我只是不知道误差来源于。