pyinstaller找不到我的程序

2024-10-02 20:36:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法让PyInstaller找到我的程序。我试过了,但还是没能成功。你知道吗

有人能告诉我如何使用PyInstaller或链接到一个简单的教程,不说像'运行这个'没有告诉你它在哪里。你知道吗

我已经告诉PyInstaller我的程序在命令提示符中的位置,但是它找不到它。你知道吗

 """
VERSION 0.1
TIDE
CREATOR: THEDUDXO / ISAAC BOON
"""

from Tkinter import *

food_storage = 100
height = 1
tide = 0
food = 100
population = 50
crabfarms = 1
pop_rise = 0
food_rise = 50
clay_income = population/5
clay = 1
tide_rise = 1
stat = '[ height:  ' +str(height)+' ]  [ tide:  '+str(tide)+' ]  [ food:  '+ str(food) +'/'+str(food_storage)+']  [  food rise:  '+str(food_rise)+' ]  [ population:  '+ str(population)+ ' ]  [ clay:  '+ str(clay)+']   [ Clay Income:  '+str(clay_income)+' ]'

def update_stat():
    global stat, stats
    stat = '[ height:  ' +str(height)+' ]  [ tide:  '+str(tide)+' ]  [ food:  '+ str(food) +'/'+str(food_storage)+']  [  food rise:  '+str(food_rise)+' ]  [ population:  '+ str(population)+ ' ]  [ clay:  '+ str(clay)+']   [ Clay Income:  '+str(clay_income)+' ]'
    stats.config(text=stat)
    print 'update_stat taceback' ,stat

def crabfarm():
    global crabfarms,clay,food_rise,Hhelp
    if clay >= 5:
        crabfarms +=1                    # $$$ note to self - Make crabfarms cost more clay each build, without it being buggy? $$$ #
        food_rise += 15
        clay = clay - 5
        print 'crabfarm check'
    else:
        Hhelp.config(text = 'Not enougth clay.')
    print 'crabfarm traceback'
    update_stat()


def granary():
    print 'granary trace'
    global food_storage,clay,Hhelp
    if clay > 4:
        print 'granary trace sucsess'
        food_storage += 10
        print clay
        clay = clay -5
    else:
        Hhelp.config(text = 'Not enougth clay.')
    update_stat()

def turn_end():
    global height, clay, stat, tide_rise, tide,population,pop_rise,food,food_rise,clay_income,game

    Hhelp.config(text='Turn ended.')

    previous_height = height
    height += clay
    clay = 0

    previous_clay = clay
    clay += clay_income

    tide += tide_rise
    tide_rise += 0.5

    pop_rise = int(population/26)

    population += pop_rise
    clay_income = int(population/5)

    food = (food - population)+food_rise
    food = min(food,food_storage)

    if clay <= 0:
        clay = 0

    if height < tide:
        Hhelp.config(text = 'Your civilization drowned!')
        end_turn.destroy()
        population = 0

    if food < 0:
        food = 0
        clay = previous_clay
    print 'endturn traceback' , stat
    update_stat()

def exit_game():
    global game
    game.destroy()
    print 'quit traceback'
    #save feature here? (add load as a seprate button prehaps in main menu)

def farm_menu():
    def Exit():
        farm.destroy()


    farm = Tk()

    frame=Frame(farm,background='grey',border='3')
    frame.pack()

    build_farm = Button(frame,text='Build a Crabfarm (5 clay)',command = crabfarm)
    build_granary = Button(frame,text='Build a Granary (5 clay)',command=granary)
    done=Button(frame,text='done',command=Exit)

    build_farm.pack(side='top')
    build_granary.pack(side='top')
    done.pack()

    farm.mainloop()

game = Tk()


frame1=Frame(background='blue',border = '3')
frame = Frame(background='grey',border='10')
frame2 = Frame(background='black',border ='5')
frame3 = Frame(background = 'orange',border='3')

frame1.pack(side='top')
frame.pack(side='left')
frame2.pack(side='right')
frame3.pack()



stats = Label(frame1,text=stat)

stats.pack()



end_turn = Button(frame2,text='End turn', command = turn_end)
Qquit= Button(frame2,text='Quit',command = exit_game,background='red')

Qquit.pack(side='right')
end_turn.pack(side='left')



Hhelp = Label(frame3,background = 'grey',text = 'Welcome to Tide! version; 0.1')

Hhelp.pack()


farms=Button(frame,text='Build Farms',command = farm_menu)

farms.pack()



game.mainloop()

Tags: textfooddefframepackstatpopulationprint
1条回答
网友
1楼 · 发布于 2024-10-02 20:36:24

不知道你的意思。。。pyinstaller非常容易使用。这是一步一步

  1. http://www.pyinstaller.org/(zip版本)下载pyinstaller
  2. 将它提取到C:\,现在应该有一个类似C:\pyinstaller-2.1\<bunchafiles>的路径
  3. 转到通常运行程序的源文件夹
  4. 按住SHIFT键并右键单击选择“在此处打开命令窗口”
  5. 现在应该在命令提示符C:\path\to\code> _
  6. 类型:python C:\pyinstaller-2.1\pyinstaller.py onefile my_main_prog.py
  7. 运行生成的exe。。。你知道吗

我继续把你的代码复制粘贴到一个文件c:\py_exp\tk_stackoverflow_thedudxo.py 我打开一个控制台,输入以下命令

cd c:\py_exp
python c:\pyinstaller\pyinstaller.py  onefile  console tk_stackoverflow_thedudxo.py

我现在有一个新文件位于c:\py_exp\dist\tk_stackoverflow_thedudxo.py

如果我双击这个可执行文件(或者从控制台/终端运行它/命令提示符)你的程序马上弹出。。。你知道吗

相关问题 更多 >