Error occur of using pyinstaller and pygsheet,, help to find solution

349 views Asked by At

I'm trying to create an exe file to distribute among users in my company. the exe file open a simple GUI (made with Tkinter), which allows the user to select a txt file from their pc and inserts the data from the txt into a Google sheet. I tested my python script before attempting to turn it into an exe and it worked great. but now, when I'm trying to use Pyinstaller it shows the following error:

Traceback (most recent call last):
    File "pygsheets\sheet.py", line 39, in __init__
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\<Awais Bin Riaz>\\AppData\\Local\\Temp\\_MEI104322\\pygsheets\\data\\sheets_discovery.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "cli.py", line 4, in <module>
    main()
  File "rps_nba\__main__.py", line 272, in main
    client = pygsheets.authorize(service_file = key_file)
  File "pygsheets\authorization.py", line 131, in authorize
  File "pygsheets\client.py", line 61, in __init__
  File "pygsheets\sheet.py", line 42, in __init__
  File "googleapiclient\_helpers.py", line 134, in positional_wrapper
  File "googleapiclient\discovery.py", line 291, in build
  File "googleapiclient\discovery.py", line 405, in _retrieve_discovery_doc
googleapiclient.errors.UnknownApiNameOrVersion: name: sheets  version: v4
[28348] Failed to execute script cli

I find some solution like:

I made a breakthrough with some testing. When I used pyinstaller without the --onefile option, I found the library for pygsheets was missing in the dist folder. I copied my pygsheets folder from the AppData\Local\Programs\Python\Python38\Lib\site-packages folder.

but I don't understand which file or folder I have to copy and where I have to paste it, and also find it

pyinstaller --add-data src-file dst-file

but don't know what is src-file and dst-file, I tried many time but error occured of this

usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME] [--add-data <SRC;DEST or SRC:DEST>]
               [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR] [--hidden-import MODULENAME]
               [--additional-hooks-dir HOOKSPATH] [--runtime-hook RUNTIME_HOOKS] [--exclude-module     EXCLUDES]
               [--key KEY] [-d {all,imports,bootloader,noarchive}] [-s] [--noupx] [--upx-exclude FILE] [-c] [-w]
               [-i <FILE.ico or FILE.exe,ID or FILE.icns or "NONE">] [--version-file FILE] [-m <FILE or XML>]
               [-r RESOURCE] [--uac-admin] [--uac-uiaccess] [--win-private-assemblies] [--win-no-prefer-redirects]
               [--osx-bundle-identifier BUNDLE_IDENTIFIER] [--runtime-tmpdir PATH] [--bootloader-ignore-signals]
               [--distpath DIR] [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a] [--clean] [--log-level LEVEL]
               scriptname [scriptname ...]
pyinstaller: error: argument --add-data: invalid add_data_or_binary value: "'C:\\Users\\AWAIS BIN RIAZ\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\pygsheets\\sheet.py';"

and this error also occured

usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME] [--add-data <SRC;DEST or SRC:DEST>]
               [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR] [--hidden-import MODULENAME]
               [--additional-hooks-dir HOOKSPATH] [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
               [--key KEY] [-d {all,imports,bootloader,noarchive}] [-s] [--noupx] [--upx-exclude FILE] [-c] [-w]
               [-i <FILE.ico or FILE.exe,ID or FILE.icns or "NONE">] [--version-file FILE] [-m <FILE or XML>]
               [-r RESOURCE] [--uac-admin] [--uac-uiaccess] [--win-private-assemblies] [--win-no-prefer-redirects]
               [--osx-bundle-identifier BUNDLE_IDENTIFIER] [--runtime-tmpdir PATH] [--bootloader-ignore-signals]
               [--distpath DIR] [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a] [--clean] [--log-level LEVEL]
               scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname

please guide me to solve this issue, any of the two method is acceptable. Thankyou in advance

0

There are 0 answers