Is there a specific way to import openpyxl in tkinter? - python

I am relatively new to writing code in tkinter, so I apologize for this question. I am writing an application in tkinter, where I want to update the values in Excel based on the entries in widgets.
I have tried installing openpyxl through pip install, and a manual install. I have moved openpyxl to the folder of my project, but has not helped at all.
from tkinter import *
from tkinter import ttk
import tkinter as tk
from datetime import datetime
from tkinter import messagebox
import os
import pandas as pd
import xlrd
import xlwt
from pandas import ExcelWriter
from pandas import ExcelFile
import sqlite3
import getpass
import openpyxl
I get error
Traceback (most recent call last):
File "C:/Users/vik.makker/Desktop/NewProj/Internal Inventory Tracking System.py", line 1, in <module>
import openpyxl
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\__init__.py", line 5, in <module>
from openpyxl.workbook import Workbook
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\workbook\__init__.py", line 5, in <module>
from .workbook import Workbook
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\workbook\workbook.py", line 8, in <module>
from openpyxl.worksheet.worksheet import Worksheet
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\worksheet\worksheet.py", line 30, in <module>
from openpyxl.cell import Cell, MergedCell
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\cell\__init__.py", line 4, in <module>
from .cell import Cell, WriteOnlyCell, MergedCell
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\cell\cell.py", line 32, in <module>
from openpyxl.utils.datetime import (
File "C:\Users\vik.makker\Desktop\NewProj\openpyxl\utils\datetime.py", line 13, in <module>
from jdcal import (
ModuleNotFoundError: No module named 'jdcal'

The error is that although you've installed openpyxl, you haven't installed all of its dependencies (could be just a mistake in how the people that wrote openpyxl specified what packages their tool required). The last line of your error message says that you will also need to install jdcal, I suspect your code will work fine after that.

Related

Why isn't pyinstaller making a Tkinter window?

It's important to know that I am using pyinstaller to package python.
tkinter works perfectly fine when I package it with only:
import tkinter
root=tkinter.Tk()
root.mainloop()
but when I add some more of my code it shows the error:
Traceback (most recent call last):
File "exec", line 1, in <module>
import tkinter
File "C:\Program Files\Python38\lib\tkinter\__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: Module use of python39.dll conflicts with this version of Python.
These are all my imports:
import discord
import subprocess
from os import getcwd
import os
import pyautogui
from threading import *
import sys
I tried using only a tkinter window with no extra code and that worked!
But when I add the rest of my code it shows the error:
Traceback (most recent call last):
File "exec", line 1, in \<module\>
import tkinter
File "C:\\Program Files\\Python38\\lib\\tkinter\__init_\_.py", line 36, in \<module\>
import \_tkinter # If this fails your Python may not be configured for Tk
ImportError: Module use of python39.dll conflicts with this version of Python.

I'm getting unstable API warning and also getting error 'pandas_datareader._utils.RemoteDataError: Unable to read URL:' [duplicate]

I am working in a virtual environment. I am able to import and work in pandas without any error but when I am trying to import pandas_datareader
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
from matplotlib import style
import pandas_datareader as web
it is giving following error -
Traceback (most recent call last):
File "stock.py", line 6, in <module>
import pandas_datareader as web
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
(env) xxxxx#xxxxx-yyyyy ~/pyt $ python stock.py
Traceback (most recent call last):
File "stock.py", line 6, in <module>
import pandas_datareader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
A solution without changing any files locally and bypass the version control of your package manager (pip) is to define is_list_like like this:
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
right before
import pandas_datareader as web
Furthermore this problem will be fixed in pandas_datareader version 0.7.0 release.
I meet this error and I found a method to solve it. My pandas and pandas_datareader versions are 0.23 and 0.6.
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas_datareader
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
Because the is_list_like is moved to pandas.api.types, I change the fred.py file which is highlighted in the picture. I replace from pandas.core.common import is_list_like with from pandas.api.types import is_list_like, and it works.
This is due to the fact that is_list_like has been moved from pandas.core.common to pandas.api.types in Pandas 0.23.0. This issue has been repaired here and will be a part of the Pandas Datareader 0.7.0 release. For now, I would recommend using the dev version of Datareader. Instructions for installing can be found in the documentation.
If you are not working with pandas_datareader. you need to check your conda environment data reader is installed or not if not install than you can import this way this.
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader as web
Edit fred.py file inside /your_installation_path/python2.7/site-packages/pandas_datareader and replace as below:
from pandas.core.common import is_list_like #COMMENT IT
from pandas.api.types import is_list_like #ADD
In Ubuntu 18.04, using Python 3.6 I resolved the error in the following way.
cd /home/username/.local/lib/python3.6/site-packages/pandas_datareader
subl fred.py
and I changed the first line of code which was
from pandas.core.common import is_list_like
to
from pandas.api.types import is_list_like

Pandas Error: cannot import name 'is_list_like' [duplicate]

I am working in a virtual environment. I am able to import and work in pandas without any error but when I am trying to import pandas_datareader
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
from matplotlib import style
import pandas_datareader as web
it is giving following error -
Traceback (most recent call last):
File "stock.py", line 6, in <module>
import pandas_datareader as web
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
(env) xxxxx#xxxxx-yyyyy ~/pyt $ python stock.py
Traceback (most recent call last):
File "stock.py", line 6, in <module>
import pandas_datareader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
A solution without changing any files locally and bypass the version control of your package manager (pip) is to define is_list_like like this:
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
right before
import pandas_datareader as web
Furthermore this problem will be fixed in pandas_datareader version 0.7.0 release.
I meet this error and I found a method to solve it. My pandas and pandas_datareader versions are 0.23 and 0.6.
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas_datareader
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
Because the is_list_like is moved to pandas.api.types, I change the fred.py file which is highlighted in the picture. I replace from pandas.core.common import is_list_like with from pandas.api.types import is_list_like, and it works.
This is due to the fact that is_list_like has been moved from pandas.core.common to pandas.api.types in Pandas 0.23.0. This issue has been repaired here and will be a part of the Pandas Datareader 0.7.0 release. For now, I would recommend using the dev version of Datareader. Instructions for installing can be found in the documentation.
If you are not working with pandas_datareader. you need to check your conda environment data reader is installed or not if not install than you can import this way this.
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader as web
Edit fred.py file inside /your_installation_path/python2.7/site-packages/pandas_datareader and replace as below:
from pandas.core.common import is_list_like #COMMENT IT
from pandas.api.types import is_list_like #ADD
In Ubuntu 18.04, using Python 3.6 I resolved the error in the following way.
cd /home/username/.local/lib/python3.6/site-packages/pandas_datareader
subl fred.py
and I changed the first line of code which was
from pandas.core.common import is_list_like
to
from pandas.api.types import is_list_like

ImportError: No module named _grabscreen

I am new to python and using this tutorial http://code.tutsplus.com/tutorials/how-to-build-a-python-bot-that-can-play-web-games--active-11117 to build a bot which plays games.
I copy-pasted the file and installed the libraries .When i tried running the file in the terminal on my mac i got this error :
Traceback (most recent call last):
File "bot.py", line 2, in <module>
import Image, ImageGrab, ImageOps
File "/Library/Python/2.7/site-packages/PIL/ImageGrab.py", line 34, in <module>
import _grabscreen
ImportError: No module named _grabscreen
Here is the complete code
import os, sys
import Image, ImageGrab, ImageOps
import time, random
from random import randrange
import win32api, win32con
from numpy import *
I think you should pay attention to the these words in the tutorial, 'Some of the code and libraries are Windows-specific. There may be Mac or Linux equivalents, but we won't be covering them in this tutorial.'.
And current version of ImageGrag only works for windows.

Python installing xlwt module error

I unzipped xlwt and tried to install from that directory, but I get the following error.
>> python setup.py install
Traceback (most recent call last):
File "setup.py", line 4, in <module>
from xlwt import __VERSION__
File "C:\Users\mypc\Desktop\xlwt-0.7.5\xlwt\__init__.py", line 3, in <module>
from Workbook import Workbook
ImportError: No module named 'Workbook'
Here's the init.py that's giving the error
__VERSION__ = '0.7.5'
from Workbook import Workbook
from Worksheet import Worksheet
from Row import Row
from Column import Column
from Formatting import Font, Alignment, Borders, Pattern, Protection
from Style import XFStyle, easyxf, easyfont, add_palette_colour
from ExcelFormula import *
Anyone know what's causing this error? I need xlwt to write to excel spreadsheets!
xlwt is Python 2.x compatable, and does not seem to work on Python 3.x. "xlwt-future" is a fork of xlwt that works for Python 3:
pip install xlwt-future
I just installed a different version of xlwt and it worked.

Categories

Resources