"Licences" module not found by xlrd - python-3.x

I've installed xlutils and am trying the following code:
from xlrd import open_workbook
input_file = open_workbook('DataTestFile.xlsx')
for s in input_file.sheets():
print('Sheet:',s.name)
for row in range(s.nrows):
values = []
for col in range(s.ncols):
values.append(s.cell(row,col).value)
print(','.join(values))
print()
(as per tutorial book found here)
I'm getting an error indicating that the licences module is not found:
Traceback (most recent call last):
File "C:\Users\xxxxxxx\workspace_python\xxxxxxx\TestPack\test_file_excel.py", line 7, in <module>
from xlrd import open_workbook
File "C:\Python34\lib\site-packages\xlrd\__init__.py", line 9, in <module>
import licences
ImportError: No module named 'licences'
However, I can confirm that the file licences.py is present in the same folder as file _ init _.py quoted above:
How come it's not recognized?

Related

Get "No module named 'pandas.tslib'" error while importing xarray

While importing xarray following error was observed. Earlier it was running fine. Does anyone have any suggestions for why?
import xarray as xr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jives/anaconda3/lib/python3.7/site-packages/xarray/__init__.py", line 4, in <module>
from .core.dataset import Dataset
File "/home/jives/anaconda3/lib/python3.7/site-packages/xarray/core/dataset.py", line 16, in <module>
from .. import conventions
File "/home/jives/anaconda3/lib/python3.7/site-packages/xarray/conventions.py", line 9, in <module>
from pandas.tslib import OutOfBoundsDatetime
ModuleNotFoundError: No module named 'pandas.tslib'

Cant use docx module: expections

In pycharm:
from docx import Document
This is the error im getting:
/Users/XYZ/PycharmProjects/XYZ/venv/bin/python "/Users/XYZ/PycharmProjects/XYZ/Intro - Hello World.py"
Traceback (most recent call last):
File "/Users/XYZ/PycharmProjects/XYZ/Intro - Hello World.py", line 1, in <module>
from docx import Document
File "/Users/XYZ/PycharmProjects/XYZ/venv/lib/python3.7/site-packages/docx.py", line 30, in <module>
from exceptions import PendingDeprecationWarning
ModuleNotFoundError: No module named 'exceptions'
Process finished with exit code 1
When I go to the directory -> site packages -> docx ->
I can find the file "exceptions.py". I do not know why it says it is missing.

AttributeError: module 'typing' has no attribute 're' in pandas Python 3.7

I can't import pd from pandas because i have this error. I search on google but I didn't find the fix for this..
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37\lib\site-packages\pandas\__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "C:\Python37\lib\site-packages\pandas\compat\__init__.py", line 431, in <module>
re_type = typing.re.Pattern
AttributeError: module 'typing' has no attribute 're'
I think this is changing underneath us as Python's typing module matures, but in our case, the issue was that we did from Typing import re, and then later did something like:
def funct(some_re: re.Pattern):
The fix was dumb. Simply change your import to be from typing import Pattern and then do:
def funct(some_re: Pattern):
Bleh. Warts.

surprise.dataset is not a package

When I try to execute this code
import surprise.dataset
file = 'ml-100k/u.data'
col = 'user item rating timestamp'
reader = surprise.dataset.Reader(line_format = col, sep = '\t')
data = surprise.dataset.Dataset.load_from_file(file, reader = reader)
data.split(n_folds = 5)
I get this error:
Traceback (most recent call last):
File "/home/user/PycharmProjects/prueba2/surprise.py", line 1, in <module>
import surprise.dataset
File "/home/user/PycharmProjects/prueba2/surprise.py", line 1, in <module>
import surprise.dataset
ModuleNotFoundError: No module named 'surprise.dataset'; 'surprise' is not a package
But surprise is installed. How can I use it?
If you want to import a submodule, instead of doing:
import surprise.dataset
do:
from surprise import dataset
then in the rest of the code, reference it as dataset instead of surprise.dataset (i.e. replace surprise.dataset.Reader with dataset.Reader). If you don’t want to update the rest of your code, you can also just import the whole surprise module instead with:
import surprise

Python 3.4 : cStringIO vs. StringIO

QUESTION
I am returning an ImportError: No module named 'cStringIO'. Unfortunately cStringIO doesn't exist anymore and I need to use StringIO as a replacement. How can I do this?
import edgar
import ftplib
from io import StringIO
ftp = ftplib.FTP(edgar.FTP_ADDR)
ftp.login()
try:
edgar.download_all(ftp, "/tmp")
except Exception as e:
print(e)
finally:
ftp.close()
OUTPUT
Traceback (most recent call last):
File "/usr/local/lib/ana/lib/python3.4/site- packages/edgar/downloader.py", line 5, in <module>
from cStringIO import StringIO
ImportError: No module named 'cStringIO'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/aranjohn/PycharmProjects/edgar/secEd.py", line 1, in <module>
import edgar
File "/usr/local/lib/ana/lib/python3.4/site- packages/edgar/__init__.py", line 1, in <module>
from .downloader import FTP_ADDR, file_list, download, download_all
File "/usr/local/lib/ana/lib/python3.4/site- packages/edgar/downloader.py", line 7, in <module>
from StringIO import StringIO
ImportError: No module named 'StringIO'
Process finished with exit code 1
StringIO no longer exists in 3.x. Use either io.StringIO for text or io.BytesIO for bytes.

Resources