0

I am trying to make an .exe file of my python script that provides an easy interface (using Tkinter) to generate Shot Charts from NBA players (using matplotlib) all over the years, this one just below:

Graphic interface

But when I tried to create the .exe using pyinstaller, it didn't worked.

Now, I've tried every possible solution I found, going from auto-py-to-exe (several tries with this one), --onefile, --onedir, to me even trying to remove the image (the NBA logo) and icon, among other things, but all of them with the same result.

In most of the tries, when I try to execute the .exe file, it takes a moment and then shows the "Failed to execute script" message.

I'm not exactly an expert or anything on programming, I'm kind of learning as I do stuff, so if someone has any ideas about what (and where) can I do to solve this (if is there a way to solve it) I would appreciate it very much.

Here I am just going to leave all the modules that the program has, just in case that it is relevant:

import numpy as np
import pandas as pd

from nba_api.stats.static import players
from nba_api.stats.endpoints import shotchartdetail
from nba_api.stats.endpoints import playercareerstats

import matplotlib.pyplot as plt
import seaborn as sns

from matplotlib import cm
from matplotlib.patches import Circle, Rectangle, Arc, ConnectionPatch
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
from matplotlib.colors import LinearSegmentedColormap, ListedColormap, BoundaryNorm
from matplotlib.path import Path
from matplotlib.patches import PathPatch

from tkinter import *
from ttkthemes import themed_tk as tk
from tkinter import font
from PIL import ImageTk,Image

I'm not sure if the rest of the code is relevant, since I don't think it has anything to do with the problem, but I can put it here if necessary.

My best guess would be that the program has a module that pyinstaller doesn't recognize properly, or that it is something that I don't have enough knowledge to understand (probably the 2nd).

Error code

Error code 2

  • Firstly, neither you nor us is clear about what the problem is, right? So for finding the problem, run this code. `pyinstaller -c -F script.py` and then run the exe after copying it to the project directory, a command prompt will open up which will show the error leading to the crash of the exe. Update the Q with the error code and let me know. – Delrius Euphoria Sep 12 '20 at 20:03
  • Just uploaded the error on the post – GabrielPast Sep 12 '20 at 20:29
  • Well, did you make this code on pycharm or something? Or did you use any virtual environment? – Delrius Euphoria Sep 12 '20 at 20:30
  • No, I made it on the default IDLE, I've been using it for a year now and got used to it. Should I have made it on a virtual environment? – GabrielPast Sep 12 '20 at 20:38
  • Try this out `pyinstaller -c -F --hiden-import matplotlib.backends.backend_tkagg script.py` and follow the same procedure as before and let me know – Delrius Euphoria Sep 12 '20 at 20:48
  • Just added the error, it seems similar to the other one, this time with pandas – GabrielPast Sep 12 '20 at 21:14
  • Take a look [here](https://stackoverflow.com/q/54093020/13382000) – Delrius Euphoria Sep 12 '20 at 21:18
  • I did as mentioned there, but now there is a new error when I try to uninstall pandas... permission error... – GabrielPast Sep 12 '20 at 23:08
  • Although when I try to run it after that, it's like it has unistalled... but if I try to open the .exe it remains with the same error (even 'remaking' it again) – GabrielPast Sep 12 '20 at 23:15
  • Its sad, ive seen many Q here on site, which failed to convert using `matplotlib`. Now i would recommend you ask a Q at github. Check [here](https://github.com/pyinstaller/pyinstaller/issues) – Delrius Euphoria Sep 12 '20 at 23:35
  • 1
    Ok, thanks for all the help! I'll see what I can find out – GabrielPast Sep 13 '20 at 03:03

0 Answers0