代码之家  ›  专栏  ›  技术社区  ›  Chris Brocious

pycharm项目在“run”上工作,但pyinstaller-onefile给出了与纸浆相关的错误

  •  1
  • Chris Brocious  · 技术社区  · 6 年前

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "tkinter\__init__.py", line 1702, in __call__
      File "example.py", line 29, in get_file
      File "pydfs_lineup_optimizer\lineup_optimizer.py", line 351, in optimize
      File "pydfs_lineup_optimizer\solvers\pulp_solver.py", line 39, in solve
      File "site-packages\pulp\pulp.py", line 1664, in solve
    AttributeError: 'NoneType' object has no attribute 'actualSolve'
    

    下面是我遇到问题的一段代码:

    import tkinter as tk
    from tkinter import *
    from tkinter import filedialog
    from tkinter.filedialog import askopenfilename
    import csv
    import time
    import os, sys
    import PIL
    from PIL import Image, ImageTk
    from tkinter.font import Font
    
    
    
    
    def get_file():
        global file
        file = tk.filedialog.askopenfilename()
    
    def run_it():
        from pydfs_lineup_optimizer import Site, Sport, get_optimizer
        optimizer = get_optimizer(Site.FANDUEL, Sport.BASEBALL)
        optimizer.load_players_from_CSV(file)
        lineup_generator = optimizer.optimize(3)
        with open('Lineup.csv', "w") as csv_file:
            writer = csv.writer(csv_file, delimiter=' ')
            for lineup in lineup_generator:
                writer.writerow([lineup])
    
    top = tk.Tk()
    top.geometry("600x337")
    if getattr(sys, 'frozen', False):
        baseDir = sys._MEIPASS
    else:
        baseDir = os.path.abspath(os.path.dirname(__file__))
    
    image = Image.open(os.path.join(baseDir, 'baseball.jpg'))
    
    photo = ImageTk.PhotoImage(image)
    L0 = Label(top, image=photo)
    
    L2 = Button(top, text="UPLOAD", fg="blue", font=font2, command=get_file).grid(row=1, column=4)
    L3 = Button(top, text="RUN", fg="blue", font=font2, command=run_it).grid(row=2, column=4)
    top.mainloop()
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   Stuart Mitchell    6 年前

    不幸的是,pyinstaller在默认情况下并没有选择它,您需要找到一种方法来打包cbc.ex公司然后告诉COIN_CMD()解算器在哪里找到它。

    COIN_CMD(path=<your_path_here>)