2

Pyinstaller doesn't see gspread.

import cv2 as cv
from time import time
import numpy as np
import dxcam
import gspread
import datetime
import wmi
from datetime import datetime, timedelta

All another lib of my project pyinstaller finding correctly.

pyinstaller myProj.py

When i run the .exe i get: ModuleNotFoundError: No module named 'gspread'

I tried copy all modules including gspread to the "dist\myProj" folder, after run the myProj.exe, i get this:

> C:\myProj\dist\myProj>myProj.exe Traceback (most recent call last):
> File " myProj.py", line 5, in <module> File
> "C:\myProj\dist\myProj\gspread\__init__.py", line 16, in <module> from
> .auth import oauth, service_account, service_account_from_dict File
> "C:\myProj\\dist\myProj\gspread\auth.py", line 16, in <module> from
> google_auth_oauthlib.flow import InstalledAppFlow File
> "C:\myProj\\dist\myProj\google_auth_oauthlib\__init__.py", line 21, in
> <module> from .interactive import get_user_credentials File
> "C:\myProj\\dist\myProj\google_auth_oauthlib\interactive.py", line 27,
> in <module> import google_auth_oauthlib.flow File
> "C:\myProj\\dist\myProj\google_auth_oauthlib\flow.py", line 63, in
> <module> import wsgiref.simple_server ModuleNotFoundError: No module
> named 'wsgiref' [2732] Failed to execute script 'myProj' due to
> unhandled exception!

What can i do to fix this?

buran
  • 13,682
  • 10
  • 36
  • 61
kokinas
  • 21
  • 2
  • Did you check [Helping PyInstaller Find Modules](https://pyinstaller.org/en/stable/when-things-go-wrong.html#helping-pyinstaller-find-modules)? Try listing it as hidden import when convert to exe. – buran Sep 26 '22 at 07:39

1 Answers1

0

first install package 'gspread' with your terminal like that :

pip install gspread

then make another exe file with this command :

pyinstaller --onefile yourPythonFilename.py

then in your project library go to dist folder and the yourPythonFilename.exe file is the file you created.

Ali
  • 376
  • 5
  • 16
  • doesn't work. I get same Error: C:\myProj\dist>myProj Traceback (most recent call last): File "myProj.py", line 5, in ModuleNotFoundError: No module named 'gspread' [704] Failed to execute script 'myProj.py' due to unhandled exception! – kokinas Sep 26 '22 at 07:04
  • @kokinas what do you see when you run pip install gspread in your terminal ? – Ali Sep 26 '22 at 07:05
  • 15 lines Requirement already satisfied, 5 lines WARNING: Ignoring invalid distribution -pencv-python (c:\users\kokinas\appdata\local\programs\python\python310\lib\site-packages) – kokinas Sep 26 '22 at 07:10