I am trying to make a date picker with tkcalendar, but everytime I try to run it, its always show me this error
Traceback (most recent call last):
File "C:\Python\Django\UJT\test.py", line 1, in <module>
from tkcalendar import *
File "C:\Python\venv\lib\site-packages\tkcalendar\__init__.py", line 26, in <module>
from tkcalendar.dateentry import DateEntry
File "C:\Python\venv\lib\site-packages\tkcalendar\dateentry.py", line 35, in <module>
from tkcalendar.calendar_ import Calendar
File "C:\Python\venv\lib\site-packages\tkcalendar\calendar_.py", line 35, in <module>
from babel import default_locale
File "C:\Python\venv\lib\site-packages\babel\__init__.py", line 29, in <module>
from babel.core import *
File "C:\Python\venv\lib\site-packages\babel\core.py", line 19, in <module>
from babel import localedata
File "C:\Python\venv\lib\site-packages\babel\localedata.py", line 26, in <module>
from UserDict import DictMixin
ModuleNotFoundError: No module named 'UserDict'
Process finished with exit code 1
I have already installed tkcalendar and update my pip, but I still get the error.
Here's my code
from tkcalendar import *
from tkinter import *
root = Tk()
cal = Calendar(root, width=12, year=2019, month=6, day=22,
bg='white', fg='black', borderwidth=2)
cal.pack(padx=10, pady=10)
root.mainloop()
please help me, thankyou
Related
All of a sudden i am getting below error while running my code in Pycharm. Earlier It was working fine. I tried changing the interpretar from virtual en to base interpreter but no resolve
Traceback (most recent call last):
File "/Users/ubhatia/PycharmProjects/ModerationReport/resources/user_keywords/keyword.py", line 3, in <module>
from robot.api.deco import library, keyword
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/__init__.py", line 43, in <module>
from robot.rebot import rebot, rebot_cli
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/rebot.py", line 40, in <module>
from robot.conf import RebotSettings
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/conf/__init__.py", line 27, in <module>
from .settings import RobotSettings, RebotSettings
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/conf/settings.py", line 16, in <module>
import glob
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/glob.py", line 4, in <module>
import re
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 127, in <module>
import functools
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/functools.py", line 21, in <module>
from collections import namedtuple
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/collections/__init__.py", line 22, in <module>
from keyword import iskeyword as _iskeyword
File "/Users/ubhatia/PycharmProjects/ModerationReport/resources/user_keywords/keyword.py", line 3, in <module>
from robot.api.deco import library, keyword
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/api/__init__.py", line 71, in <module>
from robot.model import SuiteVisitor
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/model/__init__.py", line 28, in <module>
from .body import BaseBody, Body, BodyItem, Branches
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/model/body.py", line 18, in <module>
from .itemlist import ItemList
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/model/itemlist.py", line 17, in <module>
from functools import total_ordering
ImportError: cannot import name 'total_ordering' from 'functools' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/functools.py)
This is the piece of code i am running
import time
from datetime import date, timedelta
from robot.api.deco import library, keyword
from robot.libraries.BuiltIn import BuiltIn
import pandas as pd
def get_current_date():
today = time.strftime('%d/%m/%Y')
return today
def get_yesterday_date():
today = date.today()
yesterday = today - timedelta(days=1)
return yesterday.strftime('%d/%m/%Y')
def read_excel_and_change_to_list(excel_path):
return pd.read_excel(excel_path)
print(get_current_date())
Can anyone help me out on how to resolve this issue please?
My code stopped working quite literally overnight, due to an issue with Tkinter.
I'm using PySimpleGui for my project, which was working the previous day.
When I run my program it showed the bellow error:
File "E:/Projekty Python/dcs_assistant/gui_and_video.py", line 1, in <module>
import PySimpleGUI as sg
File "C:\Users\pawni\Miniconda3\envs\dcs_assistant\lib\site-packages\PySimpleGUI\__init__.py", line 2, in <module>
from .PySimpleGUI import *
File "C:\Users\pawni\Miniconda3\envs\dcs_assistant\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 125, in <module>
tclversion_detailed = tkinter.Tcl().eval('info patchlevel')
File "C:\Users\pawni\Miniconda3\envs\dcs_assistant\lib\tkinter\__init__.py", line 2354, in __getattr__
return getattr(self.tk, attr)
AttributeError: module '_tkinter' has no attribute 'eval'
Process finished with exit code 1
Line 125 is this:
tclversion_detailed = tkinter.Tcl().eval('info patchlevel')
This, as per Tkinter documentation, should simply return the version of Tkinter library (https://tkdocs.com/tutorial/install.html).
When I ran a dummy program using just Tkinter to test if Tkinter alone works. I got another error:
Traceback (most recent call last):
File "E:/Projekty Python/dcs_assistant/test.py", line 3, in <module>
tk = tkinter.Tk()
File "C:\Users\pawni\Miniconda3\envs\dcs_assistant\lib\tkinter\__init__.py", line 2272, in __init__
self._loadtk()
File "C:\Users\pawni\Miniconda3\envs\dcs_assistant\lib\tkinter\__init__.py", line 2286, in _loadtk
tk_version = self.tk.getvar('tk_version')
AttributeError: module '_tkinter' has no attribute 'getvar'
Process finished with exit code 1
The code for the dummy program was:
import tkinter
from tkinter.constants import *
tk = tkinter.Tk()
frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
frame.pack(fill=BOTH,expand=1)
label = tkinter.Label(frame, text="Hello, World")
label.pack(fill=X, expand=1)
button = tkinter.Button(frame, text="Exit", command=tk.destroy)
button.pack(side=BOTTOM)
tk.mainloop()
I tried to uninstall and re-install Tkinter again using both pip and conda. No joy.
This is the Code that I am trying to run:
from tkinter import *
from PIL import ImageTk,Image
root = Tk()
root.title("GUI with Images")
root.iconbitmap('icon.png')
button_quit = Button(root, text=("Exit Program"), command = root.quit)
button_quit.pack()
my_img = ImageTk.PhotoImageTk(Image.open("icon.png"))
my_label = Label(image=my_img)
my_label.pack()
root.mainloop()
And this is the Error Showing:
Traceback (most recent call last):
File
"F:\Pycharm\PracticeProjects\PythonPractice\PythonApplication1\images.py",
line 2, in
from PIL import ImageTk,Image
File "F:\Pycharm\Python\lib\site-packages\PIL\ImageTk.py", line 31,
in
from . import Image
File "F:\Pycharm\Python\lib\site-packages\PIL\Image.py", line 109, in
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL'
(F:\Pycharm\Python\lib\site-
packages\PIL_init_.py)
I am trying to create my own PyEnvironment for TF-Agents.
However, this error keeps showing up:
AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
I have found out that this seems to be an issue with tensorflow-probability, but I have installed the version tensorflow-probability=0.7.0 recommended at
https://github.com/tensorflow/agents/issues/91
I have tried reinstalling and updating
tensorflow-gpu=2.0.0-beta1
tf-agents-nightly
tensorflow-probability=0.7.0
Here is a minimal code example:
from tf_agents.environments import py_environment
class myEnv(py_environment.PyEnvironment):
def __init__(self):
pass
def _reset(self):
pass
def _step(self, action):
pass
This is the full error message when running this minimum example:
Traceback (most recent call last): File ".\env_mwe.py", line 1, in <module>
from tf_agents.environments import py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\__init__.py", line 18, in <module>
from tf_agents.environments import batched_py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\batched_py_environment.py", line 33, in <module>
from tf_agents.environments import py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\py_environment.py", line 29, in <module>
from tf_agents.trajectories import time_step as ts File "C:\Python37\lib\site-packages\tf_agents\trajectories\__init__.py", line 19, in <module>
from tf_agents.trajectories import time_step File "C:\Python37\lib\site-packages\tf_agents\trajectories\time_step.py", line 28, in <module>
from tf_agents.specs import array_spec File "C:\Python37\lib\site-packages\tf_agents\specs\__init__.py", line 20, in <module>
from tf_agents.specs.distribution_spec import DistributionSpec File "C:\Python37\lib\site-packages\tf_agents\specs\distribution_spec.py", line 22, in <module>
import tensorflow_probability as tfp File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\__init__.py", line 78, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\__init__.py", line 22, in <module>
from tensorflow_probability.python import distributions File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\__init__.py", line 64, in <module>
from tensorflow_probability.python.distributions.linear_gaussian_ssm import LinearGaussianStateSpaceModel File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\linear_gaussian_ssm.py", line 41, in <module>
_matmul = linear_operator_util.matmul_with_broadcast AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
Found it!
In order to use tensorflow-gpu with tensorflow-probability, one needs to install tfp-nightly
So pip3 install --upgrade tfp-nightly did the trick
To use 2.0.0beta1 requires tfp-nightly.
I have written a python script in python 2.7 and I am facing a problem after exe conversion of this file using py2exe package. I have got the exe file but when i run, i got an error which i have mentioned below. Please note that I have saved the script file with name test.py. Please tell me the problem #Bryan Oakley
from Tkinter import *
import os
from os.path import expanduser
import time
import datetime
from docx import Document
from docx.shared import Inches
document = Document()
docx_prefix = "Doc_File_"
home_directory = expanduser("~")
folder_directory = home_directory + "\myapp"
doc_file_directory = folder_directory + "/"
if not os.path.exists(folder_directory):
os.makedirs(folder_directory)
def create_file():
now = datetime.datetime.now()
current_time = now.strftime("%Y-%m-%d %H%M%S")
file_name = docx_prefix + current_time
document = Document()
document.add_paragraph("word document")
document.save(doc_file_directory + file_name + '.docx')
main_root = Tk()
main_root.title("Toolbar")
main_root.geometry('105x26+1+1')
toolbar = Frame(main_root, bg="gray")
toolbar.pack(side="top")
create_file_button = Button(toolbar, text="Create File", command =
create_file, bg="gray", width=10)
create_file_button.pack(side="left")
main_root.mainloop()
Setup file for exe conversion using py2exe :
from distutils.core import setup
import py2exe
setup(
console=['test.py'],
options = {'py2exe': {'packages' : ['docx']}}
)
I am getting the following error after exe conversion:
C:\Python27\Lib\site-packages\py2exe\samples\scripting\dist>test.exe
Traceback (most recent call last):
File "test.py", line 6, in <module>
File "docx\__init__.pyc", line 3, in <module>
File "docx\api.pyc", line 14, in <module>
File "docx\package.pyc", line 11, in <module>
File "docx\opc\package.pyc", line 12, in <module>
File "docx\opc\part.pyc", line 12, in <module>
File "docx\opc\oxml.pyc", line 12, in <module>
File "lxml\etree.pyc", line 12, in <module>
File "lxml\etree.pyc", line 10, in __load
File "src/lxml/lxml.etree.pyx", line 92, in init lxml.etree
(src\lxml\lxml.etree.c:225327)
ImportError: cannot import name _elementpath
Module lxml isn't pure Python. It relies on DLLs written in C. You need to add etree.pyd and objectify.pyd in the py2exe package. They are in site-packages\lxml.