cx_Freeze exe不会启动

时间:2016-01-15 02:35:14

标签: python-3.x selenium exe cx-freeze

我正在使用cx_Freeze将我制作的程序变成可执行文件。我能够创建可执行文件但是当我尝试运行它时,绝对没有任何反应。我以为是模块,所以我尝试了一个简单的“Hello World!”编程成一个可执行文件,即使它没有模块,它仍然无法工作。

这是我的安装文件,它应该将程序变成可执行文件:

from cx_Freeze import setup, Executable

setup(name = 'Quick Type',
      version = '0.1',
      description = 'Typing bot',
      executables = [Executable('main.py')])

以下是我要转换的程序:

import sys
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

print("Choose a website.\n\n 1.app.typrx.com \n 2.careerstep.com \n 3.goodtyping.com  ")
choice = int(input())


while True:
    try:
        if choice < 1 or choice > 3:
            print("choose between 1-3")
            choice = int(input())
        else:
            driver=webdriver.Chrome(r'C:\Users\aaron\Downloads\chromedriver.exe')
            driver.implicitly_wait(30)
            if choice==1:
                driver.get("http://www.ultimatetypingchampionship.com/")
                submit=driver.find_element_by_xpath("//*[@id='middle-section']/div[3]/a/img")
                submit.click()
                driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')
                driver.get("http://app.typrx.com/#RacePlace:race")
                time.sleep(18)
                inputbox = driver.find_element_by_class_name("cw-QuotePanel-textToTypePanel")
                wordsarray = inputbox.find_elements_by_tag_name("span")
                li=[]
                for i in wordsarray:
                    li.append(i.text)
                writebox= driver.find_element_by_xpath("//*[@id='GWTUI']/table/tbody/tr/td/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td/table/tbody/tr/td/table/tbody/tr[2]/td/input")
                for i in li:
                    writebox.send_keys(i+" ")
                break


            elif choice==2:
                driver.get("http://www.careerstep.com/free-typing-test")
                inputbox = driver.find_element_by_class_name("text")
                wordsarray=str(inputbox.text).split()
                writebox= driver.find_element_by_tag_name("textarea")
                for i in wordsarray:
                    writebox.send_keys(i+" ")
                break


            elif choice==3:
                driver.get("http://www.goodtyping.com/test.php")
                inputbox = driver.find_element_by_id("clock")
                wordsarray=str(inputbox.text).split()
                writebox= driver.find_element_by_tag_name("textarea")
                for i in wordsarray:
                    writebox.send_keys(i+" ")
                break

    except KeyboardInterrupt:
        print("Don't press control+C")
        sys.exit(0)
    except:
        print("Unexpected error:", sys.exc_info()[0])
        raise

帮助将不胜感激。

编辑:我修好了。原来avast秘密地阻止了我的所有python脚本,如pip和cx_Freeze。我不得不在脚本文件夹中添加一个例外,它现在可以正常工作。

0 个答案:

没有答案