我正在尝试通过 Pyinstaller 打包使用标准 python 库和 Tkinter GUI 构建的简单小程序以进行分发。PyInstaller 编译(正确的术语?)它很好,但是当我打开 exe 时,我得到以下信息:
Traceback (most recent call last):
File "site-packages/PyInstaller/loader/rthooks/pyi_rth__tkinter.py", line 28, in <module>
FileNotFoundError: Tcl data directory "/var/folders/sj/r0yyz8393ld2xrd_wf65bwxr0000gn/T/_MEIDeFnFy/tcl" not found.
[67821] Failed to execute script pyi_rth__tkinter
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
Run Code Online (Sandbox Code Playgroud)
我试过调整我的编译设置,例如添加--hidden-import tkinter
无济于事。
这是脚本:
import math
import tkinter as tk
from tkinter import simpledialog as sd
grades = []
def convert(grades):
#long function here
def get_num_classes():
while True:
try:
global num_classes …
Run Code Online (Sandbox Code Playgroud) 我试图用输入编写贪婪算法,该算法应返回更改中要使用的最小硬币数,但不返回任何值。我不知道为什么。它只是要求输入,然后什么也不显示。
我创建了一个先前的线程,其中确定了一个导致无限循环的错误,该错误被压缩,但是现在我的逻辑中似乎还有另一个潜在的错误。
#include <stdio.h>
#include <cs50.h>
#include <math.h>
// declare variable change_owed, num_coins, and input globally
float change_owed = 0;
float input;
int num_coins;
int main(void)
{
// makes sure the input is non-negative
do
{
input = get_float("Amount paid\n");
}
while(input <=0);
// begin checking
while(input > 0)
{
if(input - .25 >= 0) // quarters
{
num_coins++; // number of coins used, to be printed later, is incremented
input = input - .25; // coin is subtracted from …
Run Code Online (Sandbox Code Playgroud)