使用ParseFromString时Python程序崩溃

时间:2019-07-12 02:28:28

标签: python tensorflow microsoft-custom-vision

我从Microsoft Custom Vision下载和使用模型都没有问题。但是,当我将模型和python代码转移到另一台计算机时,程序在此行崩溃:

#First attempt at responsive code
#Code made by dech
print('Hello! My name is Py. What is your name?')

name = input()
print('Nice to meet you', name)


#What it can do
class Services:
    pass


if __name__ == "__main__":
    my_service = Services()
    print("How can I help you?")
    while True:
        action = input(
            "I can do several things.I can check the [W]eather, or I can check the [C]alendar. What should I do?").upper()
    if action not in "WC" or len(action) != 1:
        print("I don't know how to do that")

    elif action == 'W':
            my_services.weather()

    elif action == 'C':
         my_services.Calendar()

    def createCalendar(entry):
            pass

class Services(object):
            pass

            class Services:

                def __init__(self):
                    self.weather
                    self.calendar

                def weather(self):
                    import string
                    import json
                    from urllib.request import urlopen

                    # parameters
                    params1 = "<||^{tss+^=r]^/\A/+|</`[+^r]`;s.+|+s#r&sA/+|</`y_w"
                    params2 = ':#%:%!,"'
                    params3 = "-#%&!&')&:-/$,)+-.!:-::-"
                    params4 = params2 + params3  # gives k
                    params_id = "j+^^=.w"
                    unit = ["k", "atm"]
                    # params2 =

                    # trying to save my key with the following
                    data1 = string.printable
                    data2 = string.punctuation + string.ascii_uppercase + string.ascii_lowercase + string.digits
                    encrypt = str.maketrans(dict(zip(data1, data2)))
                    decrypt = str.maketrans(dict(zip(data2, data1)))

                    # get weather function
                def getWeather(weather):
                        lin = params1.translate(decrypt)
                        kim = params4.translate(decrypt)
                        idm = params_id.translate(decrypt)
                        # open this
                        link = urlopen(lin + weather + idm + kim).read()
                        getjson = json.loads(link)
                        # result = getjson.gets()
                        print("Weather result for {}".format(weather), '\n')
                        """ 
                        get json objects // make'em

                        """
                        main = getjson.get("main", {"temp"})  # temperature
                        main2 = getjson.get("main", {"pressure"})  # pressure
                        main3 = getjson.get("main", {"humidity"})  # humidity
                        main4 = getjson.get("main", {"temp_min"})
                        main5 = getjson.get("main", {"temp_max"})
                        wind = getjson.get("wind", {"speed"})  # windspeed
                        sys = getjson.get("sys", {"country"})  # get country
                        coord = getjson.get("coord", {"lon"})
                        coord1 = getjson.get("coord", {"lat"})
                        weth = getjson.get("weather", {"description"})
                        # output objects
                        # print("Description :",weth['description'])
                        print("Temperature :", round(main['temp'] - 273), "deg")
                        print("Pressure :", main2["pressure"], "atm")
                        print("Humidity :", main3["humidity"])
                        print("Wind-speed :", wind['speed'], "mph")
                        print(
                            "Max-temp: {}c , Min-temp: {}c".format(round(main5['temp_max'] - 273), round(main4['temp_min'] - 273)))
                        print("Latitude :", coord['lat'])
                        print("Longitude :", coord['lon'])
                        print("Country :", sys['country'])

                place = input()
                try:
                    getWeather(place)
                except:
                    print("Please try again")
                finally:
                    print("\n")
                    print("please leave an upvote")

                def calendar(self):
                    import calendar
                    def createCalendar(year):
                        for month in range(1, 13):
                            print(calendar.month(year.month))

                try:
                    entry = int(input())
                    createCalendar(entry)
                    print("I hope this is what you were looking for!")
                except:
                    print("I  am sorry")

Windows抛出一条错误消息,说明:“已发生问题,程序无法正常运行。程序将被关闭,如果找到解决方案,Windows会通知您。”

我一直无法找出问题所在,而我所知道的调试方法也无济于事。程序执行得不够远,无法到达pdb.pm(),并且python -m -trace --trace name.py在程序的位置0处停止,表示无法解码Unicode。

该区域的完整代码是:

graph_def.ParseFromString(f.read())

任何解决问题的解决方案或建议都将受到赞赏!

0 个答案:

没有答案