我无法让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()
答案 0 :(得分:2)
不确定你的意思... pyinstaller非常容易使用。这是一步一步
C:\pyinstaller-2.1\<bunchafiles>
C:\path\to\code> _
python C:\pyinstaller-2.1\pyinstaller.py --onefile my_main_prog.py
我继续将您的代码复制并粘贴到文件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
如果我双击此可执行文件(或从控制台/终端/ cmd.exe运行它),程序会弹出...