python3.8编译可执行程序的问题
python3.8编译可执行程序的问题,按照网上的步骤走,最后报错如下C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib>pyinstaller -F -w
gui001.py
304 INFO: PyInstaller: 3.6
305 INFO: Python: 3.8.3
307 INFO: Platform: Windows-7-6.1.7601-SP1
312 INFO: wrote C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib\gu
i001.spec
341 INFO: UPX is not available.
Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py",
line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py",
line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts\pyinst
aller.exe\__main__.py", line 7, in <module>
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packa
ges\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packa
ges\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packa
ges\PyInstaller\building\build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packa
ges\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib\gui001.spe
c", line 6, in <module>
a = Analysis(['gui001.py'],
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packa
ges\PyInstaller\building\build_main.py", line 191, in __init__
raise ValueError("script '%s' not found" % script)
ValueError: script 'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Li
b\gui001.py' not found
没有gui001.py这个文件 xiaosi4081 发表于 2020-5-25 12:29
没有gui001.py这个文件
有的,自己写的程序在pycharm根目录 蓝水猎手 发表于 2020-5-25 12:31
有的,自己写的程序在pycharm根目录
发代码 蓝水猎手 发表于 2020-5-25 12:31
有的,自己写的程序在pycharm根目录
gui001文件里没有内容 from tkinter import *
from tkinter import Button
from tkinter import messagebox
import turtle
from pygame import mixer
import time
from PIL import ImageTk
import threading
# from multiprocessing import pool
class Application(Frame):
def __init__(self,master=None):
super().__init__(master)
self.master=master
self.pack()
self.createWidget()
def createWidget(self):
self.label01=Label(self,text="请告诉我今天是什么日子?",font=20, width=30,height=2)
self.label01.pack()
v1=StringVar()
self.entry01=Entry(self,textvariable=v1,bd=5)
self.entry01.pack()
self.label02 = Label(self, text="密码是4位数字",font=20,width=20,height=2)
self.label02.pack()
v2 = StringVar()
self.entry02 = Entry(self, textvariable=v2,show="*",bd=5)
self.entry02.pack()
self.button01=Button(self,text='点我一下吧!',font=20,fg='red',padx=20,pady=5,
width=10,height=2,command=self.login)
self.button01.pack()
def login(self):
username=self.entry01.get()
pwd=self.entry02.get()
if username=='结婚纪念日' and pwd=="0619":
huatu()
else:
messagebox.showinfo('陈雪专用',"牛头不对马嘴,请重新输入")
# def haigui():
# bgt = bjsz()
# huatu1=huatu()
# threads1 = []
# threads1.append(threading.Thread(target=bgt))
# threads1.append(threading.Thread(target=huatu1))
# if __name__ == '__main__':
# for t in threads:
# t.start()
def huatu():
str = ('老婆,结婚5周年快乐!!!')
# turtle.textinput('小小的惊喜')
turtle.speed(50)
turtle.setup(1800, 700, 70, 70)
turtle.color('blue', 'pink')
turtle.pensize(5)
turtle.hideturtle()
turtle.up()
turtle.goto(-655, -255)
turtle.down()
turtle.showturtle()
turtle.goto(-600, -200)
turtle.goto(-600, -120)
turtle.circle(35)
turtle.goto(-600, -200)
turtle.forward(40)
turtle.right(90)
turtle.forward(60)
turtle.hideturtle()
turtle.up()
turtle.goto(-600, -160)
turtle.down()
turtle.showturtle()
turtle.left(90)
turtle.forward(55)
turtle.right(45)
turtle.forward(20)
turtle.hideturtle()
turtle.up()
turtle.goto(-600, -145)
turtle.down()
turtle.showturtle()
turtle.goto(-545, -145)
turtle.left(90)
turtle.forward(20)
turtle.color('pink', 'pink')
turtle.begin_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(-500, -153)
turtle.down()
turtle.showturtle()
turtle.right(90)
turtle.forward(30)
turtle.left(90)
turtle.forward(30)
turtle.left(45)
turtle.circle(10.6, 180)
turtle.left(180)
turtle.circle(10.6, 180)
turtle.end_fill()
turtle.color('pink', 'pink')
turtle.begin_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(-430, -143)
turtle.down()
turtle.showturtle()
turtle.left(135)
turtle.right(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(45)
turtle.circle(17.67, 180)
turtle.left(180)
turtle.circle(17.67, 180)
turtle.end_fill()
turtle.color('pink', 'pink')
turtle.begin_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(-315, -133)
turtle.down()
turtle.showturtle()
turtle.left(135)
turtle.right(90)
turtle.forward(70)
turtle.left(90)
turtle.forward(70)
turtle.left(45)
turtle.circle(24.74, 180)
turtle.left(180)
turtle.circle(24.74, 180)
turtle.end_fill()
turtle.color('pink', 'pink')
turtle.begin_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(-187, -133)
turtle.down()
turtle.showturtle()
turtle.left(135)
turtle.right(90)
turtle.forward(70)
turtle.left(90)
turtle.forward(70)
turtle.left(45)
turtle.circle(24.74, 180)
turtle.left(180)
turtle.circle(24.74, 180)
turtle.end_fill()
turtle.color('pink', 'pink')
turtle.begin_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(-43.7, -143)
turtle.down()
turtle.showturtle()
turtle.left(135)
turtle.right(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(45)
turtle.circle(17.67, 180)
turtle.left(180)
turtle.circle(17.67, 180)
turtle.end_fill()
turtle.color('pink', 'pink')
turtle.begin_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(53.88, -153)
turtle.down()
turtle.showturtle()
turtle.right(90)
turtle.right(225)
turtle.forward(30)
turtle.left(90)
turtle.forward(30)
turtle.left(45)
turtle.circle(10.6, 180)
turtle.left(180)
turtle.circle(10.6, 180)
turtle.end_fill()
turtle.hideturtle()
turtle.up()
turtle.goto(251.28, -255)
turtle.down()
turtle.showturtle()
turtle.goto(196.28, -200)
turtle.goto(196.28, -120)
turtle.left(90)
turtle.circle(35)
turtle.goto(196.28, -200)
turtle.left(180)
turtle.forward(40)
turtle.left(90)
turtle.forward(60)
turtle.hideturtle()
turtle.up()
turtle.goto(196.28, -160)
turtle.down()
turtle.showturtle()
turtle.right(90)
turtle.forward(55)
turtle.left(45)
turtle.forward(20)
turtle.hideturtle()
turtle.up()
turtle.goto(196.28, -145)
turtle.down()
turtle.showturtle()
turtle.right(45)
turtle.forward(55)
turtle.right(45)
turtle.forward(20)
turtle.hideturtle()
turtle.up()
turtle.goto(-265, -133)
turtle.down()
turtle.showturtle()
turtle.goto(-245, 0)
turtle.right(135)
turtle.circle(35)
turtle.hideturtle()
turtle.up()
turtle.goto(-265, -133)
turtle.down()
turtle.showturtle()
turtle.goto(-305, 80)
turtle.circle(40)
turtle.hideturtle()
turtle.up()
turtle.goto(-137, -133)
turtle.down()
turtle.showturtle()
turtle.goto(-167, 0)
turtle.circle(35)
turtle.hideturtle()
turtle.up()
turtle.goto(-137, -133)
turtle.down()
turtle.showturtle()
turtle.goto(-117, 80)
turtle.circle(40)
turtle.pencolor("ORANGE")
turtle.penup()
turtle.goto(-245, 10)
turtle.write("O", move=False, align='center', font=("微软雅黑", 30, 'normal'))
turtle.pencolor("RED")
turtle.penup()
turtle.goto(-305, 90)
turtle.write("L", move=False, align='center', font=("微软雅黑", 30, 'normal'))
turtle.pencolor("YELLOW")
turtle.penup()
turtle.goto(-167, 10)
turtle.write("V", move=False, align='center', font=("微软雅黑", 30, 'normal'))
turtle.pencolor("GREEN")
# turtle.penup()
turtle.goto(-117, 90)
turtle.write("E", move=False, align='center', font=("微软雅黑", 30, 'normal'))
turtle.pencolor("PINK")
turtle.penup()
turtle.goto(300, 100)
turtle.write(str, move=False, align='center', font=("方正舒体", 30, 'normal'))
def move_pen_position(x, y):
turtle.hideturtle()# 隐藏画笔(先)
turtle.up()# 提笔
turtle.goto(x, y)# 移动画笔到指定起始坐标(窗口中心为0,0)
turtle.down()# 下笔
turtle.showturtle()# 显示画笔love = input("请输入表白话语:")
signature = "刘东&陈雪"
date = "2020.06.19"
turtle.color('red', 'pink')
time.sleep(0.5)
move_pen_position(350, -180)
turtle.hideturtle()# 隐藏画笔
turtle.write(signature,align="center",font=("方正舒体", 30, 'normal'))
move_pen_position(350, -230)
turtle.hideturtle()# 隐藏画笔
turtle.write(date,align="center",font=("方正舒体", 30, 'normal'))
window = turtle.Screen()
window.exitonclick()
# def bjsz():
# turtle.bgpic(r'jiehun.gif')# 这样设置。e68a84e799bee5baa6e997aee7ad9431333431346334
def bofang():
mixer.init()
mixer.music.load('爱很简单.mp3')
mixer.music.play()
time.sleep(1000)
mixer.music.stop()
def huitu():
root = Tk()
root.geometry("500x300+200+200")
root.title('结婚纪念日专用程序')
app = Application(master=root)
root.mainloop()
threads = []
threads.append(threading.Thread(target=bofang))
threads.append(threading.Thread(target=huitu))
if __name__ == '__main__':
for t in threads:
t.start()
# if __name__=='__main__':
# s1=bofang()
# s2=huitu()
# thre = threading.Thread(target=func, args=(3,))
蓝水猎手 发表于 2020-5-25 12:40
from tkinter import *
from tkinter import Button
from tkinter import messagebox
我看到第一行字 我酸了..... 蓝水猎手 发表于 2020-5-25 12:40
from tkinter import *
from tkinter import Button
from tkinter import messagebox
我跑了一下完全正常... 是不是编译器问题? 不要在C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib>这个目录运行pyinstaller,要在gui001.py所在的目录运行(或者在命令行cd到gui001.py所在目录) 本帖最后由 Twilight6 于 2020-5-25 13:12 编辑
蓝水猎手 发表于 2020-5-25 12:40
from tkinter import *
from tkinter import Button
from tkinter import messagebox
你是打包成exe 文件啊
有歌曲 打包别用中文名或路径 你的代码保存在pycharm的目录下,你去了python下面的lib去运行打包程序,当然就找不到gui001.py,你cd到pycharm的目录下再运行就可以了。 小白问具体怎么操作,不要说那么专业
页:
[1]