Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python cx_freeze可执行文件可以快速打开和关闭,而无需执行脚本应该执行的操作_Python_Cx Freeze_Python 3.4 - Fatal编程技术网

Python cx_freeze可执行文件可以快速打开和关闭,而无需执行脚本应该执行的操作

Python cx_freeze可执行文件可以快速打开和关闭,而无需执行脚本应该执行的操作,python,cx-freeze,python-3.4,Python,Cx Freeze,Python 3.4,首先,我对编程、python和本论坛是全新的,对于任何错误,我深表歉意 我写了一个python脚本,但希望能够在没有安装python的计算机上运行它,所以我做了一些研究,发现我需要下载一个程序才能将py转换为exe。cx_freeze是唯一支持python 3.4的版本 我按照一个流行的YouTube视频()中的说明操作,但当我双击exe时,命令框会在瞬间打开,然后关闭。有一些文字,但速度太快,我看不懂 看起来这些线程是关于同一个问题的,但它们没有得到响应。有什么想法吗 谢谢 编辑:如果有帮

首先,我对编程、python和本论坛是全新的,对于任何错误,我深表歉意

我写了一个python脚本,但希望能够在没有安装python的计算机上运行它,所以我做了一些研究,发现我需要下载一个程序才能将py转换为exe。cx_freeze是唯一支持python 3.4的版本

我按照一个流行的YouTube视频()中的说明操作,但当我双击exe时,命令框会在瞬间打开,然后关闭。有一些文字,但速度太快,我看不懂

看起来这些线程是关于同一个问题的,但它们没有得到响应。有什么想法吗

谢谢

编辑:如果有帮助,这是我的setup.py

from cx_Freeze import setup, Executable

setup(
name = "Teacher Pages Search" ,
version = "1" ,
description = "By Gambiteer" , executables = [Executable("Teacher Pages Search.py")] ,
)
这是教师页面搜索.py

import urllib.request
import html.parser
import webbrowser

class MyHTMLParser(html.parser.HTMLParser):
    def __init__(self):
        super().__init__(False)
        self.teacherLink = False
        self.url = ""

    def handle_starttag(self, tag, attrs):
        if tag == 'a':
            for combo in attrs:
                if "sw-directory-item" in combo[1]:
                    self.teacherLink = True
                if self.teacherLink is True:
                    if "http:" in combo[1]:
                        self.url = combo[1]


    def handle_data(self, data):
        data = data.lower()
        data = data.replace("'","")
        data = data.replace("\\","")
        data = data.replace(" ","")
        if self.teacherLink is True:
            for teacher in teacherList:
                if teacher in data:
                    webbrowser.open(self.url)
        self.teacherLink = False


teacherListInput = input("Enter the last name of your teachers, without punctuation, separated by commas:\n")
teacherListInput = teacherListInput.replace(" ","")
teacherList = list()
while teacherListInput.find(',') != -1:
    commaLoc = teacherListInput.find(',')
    teacherName = teacherListInput[0:commaLoc]
    teacherList.append(teacherName)
    teacherListInput = teacherListInput[commaLoc+1:]
teacherList.append(teacherListInput)

f = urllib.request.urlopen("http://www.scarsdaleschools.k12.ny.us/site/Default.aspx?PageType=1&SiteID=65&ChannelID=94&DirectoryType=6")
webpage = f.read()
parser = MyHTMLParser()
html_parser = html.parser.HTMLParser()
unescaped = html_parser.unescape(str(webpage))
parser.feed(unescaped)

input("Press enter to exit")

可以使用.bat文件运行exe文件。创建新的bat文件,在其中插入
TeacherPagesSearch.exe 2>log.txt
将您的exe重命名为
TeacherPagesSearch.exe
,然后运行bat文件。然后将错误从log.txt复制到post。或者,在命令提示符下运行exe,这意味着错误会停留足够长的时间以供读取。@ThomasK我已经完成了上述所有步骤。但我得到的是“没有名为queue的模块”和“没有名为urllib3的模块”。如何解决这个问题??安装urllib3模块后,我并没有收到该错误,但当我尝试安装队列时,它显示“找不到满足要求的版本”