Cant use docx module: expections - python-3.x

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.

Related

Import Image Module error while generating qrcode

I installed qrcode 7.3.1 and Image 1.5.33. Pillow 9.0.0 is also installed during Image install. But while running following example from qrcode documentation
import qrcode
img = qrcode.make('Some data here')
type(img) # qrcode.image.pil.PilImage
img.save("some_file.png")
Following error generates
Traceback (most recent call last):
File "C:\****\venv\lib\site-packages\qrcode\image\pil.py", line 5, in <module>
from PIL import Image, ImageDraw
File "C:\****\venv\lib\site-packages\PIL\Image.py", line 30, in <module>
import logging
File "C:\****\himal\anaconda3\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
File "C:\****\anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\****\anaconda3\lib\linecache.py", line 11, in <module>
import tokenize
File "c:\users\himal\anaconda3\lib\tokenize.py", line 35, in <module>
from token import EXACT_TOKEN_TYPES
ImportError: cannot import name 'EXACT_TOKEN_TYPES' from 'token' (***\token.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\****\scan_qrcode.py", line 2, in <module>
img = qrcode.make('Some data here')
File "C:\****\venv\lib\site-packages\qrcode\main.py", line 13, in make
return qr.make_image()
File "C:\****\venv\lib\site-packages\qrcode\main.py", line 296, in make_image
from qrcode.image.pil import PilImage
File "C:\****\venv\lib\site-packages\qrcode\image\pil.py", line 7, in <module>
import Image
ModuleNotFoundError: No module named 'Image'
Python 3.8 is current python version.

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'

Issues tokenizing text

Started text analysing, and eventually ran into a need for downloading Corpora in using PyCharm2019 as IDE. Not really sure what traceback message wants me to do, since I used PyCharm's own lib import interface to enable Corpora already. Why does an error stating that Corpora is not available to the code keep reappearing?
Imported TextBlob, tried to do a line like: from textblob import TextBlob...view code below
from textblob import TextBlob
TextBlob(train['tweet'][1]).words
print("\nPRINT TOKENIZATION") # own instruction to allow for knowing what code result delivers
print(TextBlob(train['tweet'][1]).words)
….
Tried to install via nltk, no luck...error when downloading 'brown.tei'
showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\jcst\AppData\Local\Programs\Python\Python37-32\lib\tkinter__init__.py", line 1705, in call
return self.func(*args)
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\nltk\downloader.py", line 1796, in _download
return self._download_threaded(*e)
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\nltk\downloader.py", line 2082, in _download_threaded
assert self._download_msg_queue == []
AssertionError
Traceback (most recent call last):
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\decorators.py", line 35, in decorated
return func(*args, **kwargs)
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\tokenizers.py", line 57, in tokenize
return nltk.tokenize.sent_tokenize(text)
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\nltk\tokenize__init__.py", line 104, in sent_tokenize
tokenizer = load('tokenizers/punkt/{0}.pickle'.format(language))
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\nltk\data.py", line 870, in load
opened_resource = _open(resource_url)
Resource File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\nltk\data.py", line 995, in open
punkt not found.
Please use the NLTK Downloader to obtain the resource:
return find(path, path + ['']).open()
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\nltk\data.py", line 701, in find
import nltk
nltk.download('punkt')
For more information see: https://www.nltk.org/data.html
Attempted to load tokenizers/punkt/english.pickle
Searched in:
- 'C:\Users\jcst/nltk_data'
- 'C:\Users\jcst\PycharmProjects\TextMining\venv\nltk_data'
- 'C:\Users\jcst\PycharmProjects\TextMining\venv\share\nltk_data'
- 'C:\Users\jcst\PycharmProjects\TextMining\venv\lib\nltk_data'
- 'C:\Users\jcst\AppData\Roaming\nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
- ''
raise LookupError(resource_not_found)
LookupError:
Resource punkt not found.
Please use the NLTK Downloader to obtain the resource:
import nltk
nltk.download('punkt')
For more information see: https://www.nltk.org/data.html
Attempted to load tokenizers/punkt/english.pickle
Searched in:
- 'C:\Users\jcst/nltk_data'
- 'C:\Users\jcst\PycharmProjects\TextMining\venv\nltk_data'
- 'C:\Users\jcst\PycharmProjects\TextMining\venv\share\nltk_data'
- 'C:\Users\jcst\PycharmProjects\TextMining\venv\lib\nltk_data'
- 'C:\Users\jcst\AppData\Roaming\nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
- ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/jcst/PycharmProjects/TextMining/ModuleImportAndTrainFileIntro.py", line 151, in
TextBlob(train['tweet'][1]).words
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\decorators.py", line 24, in get
value = obj.dict[self.func.name] = self.func(obj)
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\blob.py", line 649, in words
return WordList(word_tokenize(self.raw, include_punc=False))
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\tokenizers.py", line 73, in word_tokenize
for sentence in sent_tokenize(text))
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\base.py", line 64, in itokenize
return (t for t in self.tokenize(text, *args, **kwargs))
File "C:\Users\jcst\PycharmProjects\TextMining\venv\lib\site-packages\textblob\decorators.py", line 38, in decorated
raise MissingCorpusError()
textblob.exceptions.MissingCorpusError:
Looks like you are missing some required data for this feature.
To download the necessary data, simply run
python -m textblob.download_corpora
or use the NLTK downloader to download the missing data: http://nltk.org/data.html
If this doesn't fix the problem, file an issue at https://github.com/sloria/TextBlob/issues.

Why am i recieving this attribute error when using the requests module?

I am trying to run this code:
import requests
import json
page = requests.get('https://www.wikipedia.org/')
But i continue to recieve this error:
AttributeError: module 'cgi' has no attribute 'FieldStorage'
This code works on one of my computers, but not the other.
Any ideas? Also, i'm not even using the cgi module, so I don't know where this is coming from.
Below is the full traceback:
Traceback (most recent call last):
File "C:/Users/Larson/AppData/Local/Programs/Python/Python36-
32/tetshjwbrifvheruiher.py", line 2, in <module>
import requests
File "C:\Users\Larson\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\requests\__init__.py", line 97, in <module>
from . import utils
File "C:\Users\Larson\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\requests\utils.py", line 11, in <module>
import cgi
File "C:/Users/Larson/AppData/Local/Programs/Python/Python36-32\cgi.py", line
2, in <module>
form = cgi.FieldStorage()
AttributeError: module 'cgi' has no attribute 'FieldStorage'

"Licences" module not found by xlrd

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?

Resources