Anaconda Selenium与webdriver有关

时间:2017-10-07 18:21:40

标签: python selenium webdriver selenium-chromedriver geckodriver

我一直在努力弄清楚为什么我一直在尝试使用硒时遇到错误。我在我工作的公司的/ home / user unix驱动器上使用本地安装的anaconda3。我已经安装了硒,看似没有问题,但是当我尝试以下内容时:

 from selenium import webdriver
 driver = webdriver.Firefox()

它失败并显示以下消息:

WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

我尝试下载最新的chromedriver并尝试使用它,我尝试安装另一个壁虎驱动程序,我尝试了各种各样的东西。但没有任何工作。我很乐意提供任何额外的信息,我只想在某个时候开始实现......

谢谢!

2 个答案:

答案 0 :(得分:0)

import scipy.fftpack as fft
from scipy.io import wavfile
import numpy as np
from scipy.signal import hanning
import math



def readNormalize(location):

    samplerate, data = wavfile.read(location)

    leftChan = data.T[0] # first track of audio
    rightChan = data.T[1]

    length = len(leftChan)
    fftLeft = fft.fft(leftChan[0:], length)
    fftRight = fft.fft(rightChan[0:], length)

    #length is half(positive frequency) of the the fft data, because other half is negative (complex conjugate)
    length = int(length/2)

    #getting the normalization value
    ownSum = 0;
    for i in range(0, length):
        ownSum += abs(fftLeft[i])
    normalizer = 1/ownSum

    amplitudesRight = []
    phasesRight = []

    phasesLeft = []
    amplitudesLeft = []

    #normalizing and setting the phases
    for i in range(0,length):
        #LEFT CHAN
        amplitudesLeft.append((abs(fftLeft[i])*normalizer))
        phasesLeft.append(0)
        #RIGHT CHAN
        amplitudesRight.append((abs(fftRight[i])*normalizer))
        phasesRight.append((math.pi/2))

        #TRIED THIS ASWELL BUT CAN'T APPEND LIKE THIS
        #fftLeft[i] = (abs(fftLeft[i])*normalizer)
        #fftLeft[i][i] = 0

        #fftRight[i] = (abs(fftRight[i])*normalizer)
        #fftRight[i][i] = math.pi/2


    #putting the phases and amps back to complex form(at least trying)
    matrixLeft = np.matrix([amplitudesLeft, phasesLeft], dtype=np.complex128)
    matrixRight = np.matrix([amplitudesRight, phasesRight], dtype=np.complex128)

    #ifft for the complex
    ifftLeft = fft.ifft(matrixLeft)
    ifftRight = fft.ifft(matrixRight)

    #putting all the data back together, 
    #doesn't work, says that matrix has to be 2-dimensional
    outputMatrix = np.matrix([ifftLeft, ifftRight],dtype=np.int16)

    wavfile.write('test.wav',samplerate, outputMatrix)

答案 1 :(得分:0)

好的,通过对这个问题的回答的组合,我已经弄清楚(我认为)出了什么问题。我在我公司的服务器上使用linux anaconda安装,我相信这意味着我的python无法访问浏览器驱动程序。遗憾的是,解决方案是在本地安装anaconda,手动下载/解压缩/安装selenium和geckodriver,然后确保将整个“executable_path = path”参数传递给Firefox方法。由于某种原因,这对Chrome不起作用,我认为这与我工作机器上不可更改的安全规范有关。如果任何一部分听起来不正确,请随意插入并更清楚地了解问题。谢谢!