Traceback (most recent call last):
File "tkinter/__init__.py", line 1705, in __call__
File "script.py", line 726, in
File "script.py", line 536, in calendar
File "tkcalendar/calendar_.py", line 211, in __init__
File "babel/dates.py", line 314, in get_day_names
File "babel/core.py", line 641, in days
File "babel/core.py", line 364, in _data
File "babel/localedata.py", line 111, in load
File "babel/localedata.py", line 111, in load
File "babel/localedata.py", line 117, in load
ModuleNotFoundError: No module named 'babel.numbers'
tkcalendar folder under
venv/lib/python3.x/site-packages of your project folder.
calendar.py, add an additional import for the missing module.
from babel.dates import format_date, parse_date, get_day_names, get_month_names
from babel.numbers import * # Additional Import
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 568, in getdefaultlocale
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 495, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
To Solve the above issue you will need to add the below variables in your .profile or .bash_profile
From the Launchpad, open the Terminal
Nano is an easy to use editor
Copy the below lines of code
Press Ctrl+O to save the lines
Press Return to Save
Press Ctrl+X to Exit
To verify that the variables have been added to the .profile, use the below code in the terminal
open -e .profile
Try running your program once again. If the issue has not been resolved, use the same approach with the file
Operating System: Mac OS
The below solution worked perfectly
pyinstaller script_name.py --hidden-import ttkthemes
Copy the ttkthemes folder from venv/lib/python3.x/site-packages folder in your distribution folder (dist)
gspread loses connection with the Google API probably every 10 minutes. This can be easily tackled by calling a function or Class which reconnects to the database.
from oauth2client.service_account import ServiceAccountCredentials
from datetime import datetime
from datetime import timedelta
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
workbook1 = client.open("File_Name")
w1 = workbook1.worksheet("Sheet1")
w2 = workbook1.worksheet("Sheet2")
if datetime.now() > program_start_time + timedelta(minutes=10):
worksheet1, worksheet2 = connect_database()
program_start_time = datetime.now() #Resets the Program Start Time
gspread documentation does not have any examples of adding formulas to the cells. If you try to use them with
update_cell methods it records them as a string and not as a Formula.
You should instead use the
Updating a Single Cell, considering you know the exact Row and Column Number
Updating a Single Cell, considering you the exact Row and Column Number are not known
cell = worksheet2.find("David Letterman")
row_number = cell.row
I was facing a 5 second time delay adding data to Google Spreadsheets while using the gpread library. Web search revealed the same with other users as well.
Web search led me to pygsheets, a user seemed to claim that it is much faster when writing data into Google Spreadsheets, but my experience has been different.
Pygsheets takes a minimum 9 seconds to save a record compared to 5 seconds with gpread. If a coder has had a better experience, kindly do share your feedback.
There are few tutorials online for pygsheets, I am assuming the slowness of the system might be the reason.
import pygsheets from oauth2client.service_account import ServiceAccountCredentials scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope) client = pygsheets.authorize(service_file='client_secret.json') workbook = client.open("Spreadsheet_File_Name") worksheet1 = workbook.worksheet_by_title("Sheet1") rowcount=worksheet1.rows row_value=['a','b','c'] worksheet1.insert_rows(row=rowcount,number=1, values=row_value,inherit=True) #worksheet1.add_rows(1) #worksheet1.update_row(rowcount+1,values=row_value)
If you get an error message like one of these:
TypeError: 'int' object is not callable
TypeError: 'float' object is not callable
TypeError: 'str' object is not callable
This probably means that you are trying to call a method when a property with the same name is already available.
Simply change the method call into a property access.
For example, if a line like this causes an error message like one of those above:
Try changing the line to this:
.grid method of a widget always returns None. So ensure the the
.grid method of the Entry Widget is always on a separate line.
Under the Terminal, type
touch ~/.profile to resolve the issue