今天,我想把一个python文件转成exe,然后发给朋友看
转换的代码是这样的(用的是cmd)
pyinstaller -F D:\abab\file.py
运行exe后,它给我报了个这样的错误:
屏幕截图:
import time
import os
def calculator():
shu1 = int(input("Input number:"))
fh = input("Input operator symbol:")
shu2 = int(input("Input number:"))
if fh == "+":
print(shu1 + shu2)
elif fh == "-":
print(shu1 - shu2)
elif fh == "*":
print(shu1 * shu2)
elif fh == "/":
print(shu1 / shu2)
elif fh == "//":
print(shu1 // shu2)
else:
print('Error!')
print(
'''
This is DOS made by Li-huihang
Version: beta 1.0.0
For help, enter "help"
''')
while True:
zhiling = input(">>>") # 出问题的那一行
if zhiling == "calculator":
calculator()
elif zhiling == "help":
with open("help.txt", "r", encoding="utf-8") as help0:
help1 = help0.read()
print(help1)
elif zhiling == "time":
print(time.ctime())
elif zhiling == "exit":
break
elif zhiling == "shutdown":
os.system("shutdown -s -t 0")
elif zhiling == "reboot":
os.system("shutdown -r -t 0")
elif zhiling == "countdown":
countdown = input("countdown time:")
while countdown != 0:
time.sleep(1)
countdown -= 1
else:
print("Error!")
Python版本:3.10
Windows:11
帮你打包了一下,在我电脑上运行没有问题,你试试
链接: https://pan.baidu.com/s/1aymw9i9ip6sYqITSApq1_w
提取码: e6kt