0

I recently made a script, which is a single function fill(), runs in PyCharm with no problems

I used pyinstaller to convert to .exe: pyinstaller --onefile main.py: Works great

I added the following function: around fill()

chargebee.configure(site='site-address', api_key='api_key')
subscription_key = "subscription_key"

def check_subscription(subscription_key):
    subscription = chargebee.Subscription.retrieve(subscription_key)
    if subscription.subscription.status == "active":
        fill()
    else:
        print("Error is here1")
        print("Subscription is either not active or is having an issue, please check to make sure your subscription is valid if you continue haveing issues")
        return False
        return False

if __name__ == '__main__':
    print("Starting:")
    check_subscription(subscription_key)

This runs perfectly in Pycharm but after pyinstaller converts it to .exe.

I run it and it returns: "OS Error: Could not find a suitable TLS CA certificate bundle invalid path C:\Users\username\AppData\Local\Temp_MEI70082\chargebee\ssl\ca-certs.crt"

This makes sense as There is no folder _MEI70082\

I have tried:

pyinstaller --onefile --add-data "venv\Lib\site- packages\chargebee\ssl\ca-certs.crt;chargebee\ssl main.py"

pyinstaller --onefile--paths "C:\Users\username\PycharmProjects\YP_Key_package_2\venv\Lib\site-packages\chargebee\ssl" main.py

But I am still getting the same error.

Any thoughts?

jcruzer
  • 77
  • 6
  • Remove the bare try/except, so that you can see the original exception message! It is a bad practice to use a bare except. You will never find bugs, because everything is ignored and your custom error message is mostly a false expectation. – phibel Apr 08 '23 at 10:33
  • @phibel Thank you this was very helpful, I was able to find the root of the problem, but I am not sure how to fix that. – jcruzer Apr 08 '23 at 17:46
  • 1
    Freezing a python application with pyinstaller is mostly not plug'n'play. Running the exe will extract the freezed code into a temporary folder like: C:\Users\username\AppData\Local\Temp_MEI70082 . You can print the path `print(sys._MEIPASS)` and hold the exe by adding a longer sleep before the crash in your program `time.sleep(600)`. Than you could inspect what pyinstaller has packed/extracted. – phibel Apr 08 '23 at 18:56
  • 1
    However, your idea with manually adding the missing certificates is the correct way. I usually find it easier to work with a spec file than to do everything on the command line. With a spec file it is also well documented for later how to create an exe: https://pyinstaller.org/en/stable/man/pyi-makespec.html and https://pyinstaller.org/en/stable/spec-files.html If you have to do it again in 6 months... ;-) – phibel Apr 08 '23 at 19:06

0 Answers0