Python installing xlwt module error - python

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.

Related

Error Import awswrangler: AttributeError: module 'multiprocessing' has no attribute 'connection'

I have a python script that uses the lib awswrangler. Today my scrpit started to give errors in the import of the library and I don't know what is happening.
I'm running the script in a docker container with image python: 3.8
Example:
import awswrangler as wr
print(wr.__version__)
Error:
Traceback (most recent call last):
File "src/avec/automation/TaskBaseUserPass.py", line 1, in <module>
from awswrangler.pandas import Pandas
File "/usr/local/lib/python3.8/site-packages/awswrangler/__init__.py", line 17, in <module>
from awswrangler.pandas import Pandas # noqa
File "/usr/local/lib/python3.8/site-packages/awswrangler/pandas.py", line 45, in <module>
class Pandas:
File "/usr/local/lib/python3.8/site-packages/awswrangler/pandas.py", line 273, in Pandas
def _read_csv_once_remote(send_pipe: mp.connection.Connection, session_primitives: "SessionPrimitives",
AttributeError: module 'multiprocessing' has no attribute 'connection'
I have been experienced the same issue today when trying to import awswrangler. For me, downgrading the following dependencies helped:
pip install fsspec==0.6.3 PyAthena==1.10.2 s3fs==0.4.0
It seems that one or more of them were causing the problem.
If your code uses multiprocessing.connection.Listener or multiprocessing.connection.Client, then you should use:
import multiprocessing.connection
If you just use
import multiprocessing
.. then your code might get an ImportError or not. It depends on other modules. If an other module imports multiprocessing.connection, then it will work.
But I guess you don't want random behavior, and that's why you should import multiprocessing.connection.
I managed to run version 3.6, the library has a problem with mp.connection.Connection in current python versions

Is there a specific way to import openpyxl in tkinter?

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.

ImportError: No module named 'xlwings' using Anaconda Python Distribution in Windows 7

I'm trying to learn xlwings for in Windows 7 but I get the following error when importing the xlwings module in python IDLE
>>> import xlwings
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import xlwings
ImportError: No module named 'xlwings'
>>>
I installed Python using the Anaconda distribution and path variable correctly includes the site-packages
C:\Users\xxx\Anaconda3\Lib\site-packages;
I'm using Excel 2013. Any ideas?

openpyxl for Python 3 gives StringIO error

When I try to load a workbook in Python 3.3 using openpyxl, I get a "No module named 'StringIO'" error:
In [5]: load_workbook(FileName)
Traceback (most recent call last):
File "<ipython-input-6-c4f3bc35f522>", line 1, in <module>
load_workbook(FileName)
File "C:\WinPython-64bit-3.3.2.3\python-3.3.2.amd64\lib\site-packages\openpyxl-1.6.2-py3.3.egg\openpyxl\reader\excel.py", line 112, in load_workbook
f = repair_central_directory(filename, is_file_instance)
File "C:\WinPython-64bit-3.3.2.3\python-3.3.2.amd64\lib\site-packages\openpyxl-1.6.2-py3.3.egg\openpyxl\reader\excel.py", line 59, in repair_central_directory
from StringIO import StringIO
ImportError: No module named 'StringIO'
I am aware that StringIO is not available in Python 3, but then again, I am using the py3.3 version of openpyxl (or so I think...?). However, when I try to find the file that calls StringIO, it is not in the directory noted in the traceback. Have I installed something incorrectly? Or is something else going on here?
Thanks in advance.
This should have been resolved in openpyxl 1.7

export xlwt to open an excel sheet

i am using "import xlwt" to create new excel sheet but it is throwing the following error?
Traceback (most recent call last):
File "xl.txt", line 1, in
import xlwt
ImportError: No module named xlwt
How to solve this problem ?
You need to install package xlwt.
You will get the package here

Categories

Resources