执行从python文件创建的exe时在控制台中显示警告,需要帮助隐藏警告

时间:2020-03-31 05:44:50

标签: python warnings exe pyinstaller pygsheets

我需要使用Pyinstaller库创建的“隐藏可执行文件中的警告”的帮助,以下是我在创建可执行文件时使用的命令。

pyinstaller -y -F "D:/Vipul Garg Backup/ABCD/PythonScript/DataTransformationFile.py"

我正在使用Pyinstaller 3.6版和Python 3.7.5,并且尝试在.spec文件中进行以下更改。

1.for d in a.datas:
    if 'pyconfig' in d[0]: 
        a.datas.remove(d)
        break   
2.a.datas = list({tuple(map(str.upper, t)) for t in a.datas})

但是什么都没有解决,仍然在下面发出警告。

WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "site-packages\pygsheets\sheet.py", line 37, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\VIPUL~1.GAR\\AppData\\Local\\Temp\\_MEI165202\\pygsheets\\data\\sheets_discovery.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\__init__.py", line 36, in autodetect
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\file_cache.py", line 33, in <module>
ModuleNotFoundError: No module named 'oauth2client'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\file_cache.py", line 37, in <module>
ModuleNotFoundError: No module named 'oauth2client'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\__init__.py", line 41, in autodetect
  File "c:\users\vipul.garg\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\googleapiclient\discovery_cache\file_cache.py", line 41, in <module>
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "site-packages\pygsheets\drive.py", line 49, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\VIPUL~1.GAR\\AppData\\Local\\Temp\\_MEI165202\\pygsheets\\data\\drive_discovery.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\__init__.py", line 36, in autodetect
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\file_cache.py", line 33, in <module>
ModuleNotFoundError: No module named 'oauth2client'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\googleapiclient\discovery_cache\file_cache.py", line 37, in <module>
ModuleNotFoundError: No module named 'oauth2client'

我在脚本中使用了以下导入。

import pandas as pd
from pandas import ExcelWriter
from datetime import date
import csv
from xlsxwriter.workbook import Workbook
import glob
import json
import os
import sys
import warnings
import pygsheets
import time
import smtplib
import linecache

我已将以下代码添加到我的python文件中,以忽略警告,并且当我通过Pycharm运行python脚本时,它没有显示任何警告。

 if not sys.warnoptions:
    warnings.simplefilter("ignore")

0 个答案:

没有答案
相关问题