while using wikipedia module in a python project shows this error - python

MY CODE:
import wikipedia
from wikipedia import *
search=wikipedia.search("apple")
print(search)
ERROR:
File "c:\Users\user\OneDrive\Desktop\demoprojects\web scraping\wikipedia.py", line 2, in <module>
import wikipedia
File "c:\Users\user\OneDrive\Desktop\demoprojects\web scraping\wikipedia.py", line 7, in <module>
search=wikipedia.search("apple")
AttributeError: partially initialized module 'wikipedia' has no attribute 'search' (most likely due to a circular import)
when i used pip install wikipedia it shows this:
Requirement already satisfied: wikipedia in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (1.4.0)
Requirement already satisfied: beautifulsoup4 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from wikipedia) (4.9.3)
Requirement already satisfied: requests<3.0.0,>=2.0.0 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from wikipedia) (2.26.0)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2020.12.5)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (1.26.4)
Requirement already satisfied: soupsieve>1.2 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from beautifulsoup4->wikipedia) (2.2.1)

"c:\Users\user\OneDrive\Desktop\demoprojects\web scraping\wikipedia.py"
You have a file named wikipedia.py. When you do import wikipedia, you are basically importing your own file instead of wikipedia module. So rename you file to something else.

Related

YouTube video viewer program

I am trying to use the Youtube viewer program on someone's YouTube videos. The source code of this program can be found on the GitHub page.
There is a problem in the import statements, though.
In the YouTube viewer -> youtubeviewer -> download_driver.py file, so this page, there is an import statement.
import undetected_chromedriver._compat as uc
At first when I tried to run this program, the following error pops up:
ModuleNotFoundError: No module named 'undetected_chromedriver'
I eventually installed it using the python3 -m pip install undetected_chromedriver command. Everything ran smoothly until the statement above. The command prompt popped up the following error message.
Traceback (most recent call last):
File "C:\Users\14725\YouTube-Viewer\youtube_viewer.py", line 42, in <module>
from youtubeviewer.download_driver import *
File "C:\Users\14725\YouTube-Viewer\youtubeviewer\download_driver.py", line 29, in <module>
import undetected_chromedriver._compat as uc
ModuleNotFoundError: No module named 'undetected_chromedriver._compat'
I checked again if I had installed the module by using the python3 -m pip install undetected_chromedriver command. The following messages popped up:
Requirement already satisfied: undetected_chromedriver in c:\users\14725\appdata\roaming\python\python39\site-packages (3.4)
Requirement already satisfied: requests in c:\users\14725\appdata\roaming\python\python39\site-packages (from undetected_chromedriver) (2.28.0)
Requirement already satisfied: selenium>=4.0.0 in c:\users\14725\appdata\roaming\python\python39\site-packages (from undetected_chromedriver) (4.8.0)
Requirement already satisfied: websockets in c:\users\14725\appdata\roaming\python\python39\site-packages (from undetected_chromedriver) (10.4)
Requirement already satisfied: certifi>=2021.10.8 in c:\users\14725\appdata\roaming\python\python39\site-packages (from selenium>=4.0.0->undetected_chromedriver) (2022.5.18.1)
Requirement already satisfied: trio~=0.17 in c:\users\14725\appdata\roaming\python\python39\site-packages (from selenium>=4.0.0->undetected_chromedriver) (0.22.0)
Requirement already satisfied: urllib3[socks]~=1.26 in c:\users\14725\appdata\roaming\python\python39\site-packages (from selenium>=4.0.0->undetected_chromedriver) (1.26.9)
Requirement already satisfied: trio-websocket~=0.9 in c:\users\14725\appdata\roaming\python\python39\site-packages (from selenium>=4.0.0->undetected_chromedriver) (0.9.2)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\14725\appdata\roaming\python\python39\site-packages (from requests->undetected_chromedriver) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in c:\users\14725\appdata\roaming\python\python39\site-packages (from requests->undetected_chromedriver) (3.3)
Requirement already satisfied: cffi>=1.14 in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (1.15.0)
Requirement already satisfied: sniffio in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (1.3.0)
Requirement already satisfied: sortedcontainers in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (2.4.0)
Requirement already satisfied: async-generator>=1.9 in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (1.10)
Requirement already satisfied: outcome in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (1.2.0)
Requirement already satisfied: attrs>=19.2.0 in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (21.4.0)
Requirement already satisfied: exceptiongroup>=1.0.0rc9 in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (1.1.0)
Requirement already satisfied: wsproto>=0.14 in c:\users\14725\appdata\roaming\python\python39\site-packages (from trio-websocket~=0.9->selenium>=4.0.0->undetected_chromedriver) (1.2.0)
Requirement already satisfied: PySocks!=1.5.7,<2.0,>=1.5.6 in c:\users\14725\appdata\roaming\python\python39\site-packages (from urllib3[socks]~=1.26->selenium>=4.0.0->undetected_chromedriver) (1.7.1)
Requirement already satisfied: pycparser in c:\users\14725\appdata\roaming\python\python39\site-packages (from cffi>=1.14->trio~=0.17->selenium>=4.0.0->undetected_chromedriver) (2.21)
Requirement already satisfied: h11<1,>=0.9.0 in c:\users\14725\appdata\roaming\python\python39\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium>=4.0.0->undetected_chromedriver) (0.14.0)
Which I think these have indicated that I have the module installed. What should I do to run this program? Have I missed something?
There was an important update of undetected_chromedriver recently. I recommend you to install the latest known stable version with:
pip install undetected-chromedriver==3.2.1

How to import and use PyWhatKit on Google Colaboratory?

I wanted to automate sending messages on WhatsApp from Google Colab using the pywhatkit library. So far I have tried doing:
pip install pywhatkit
Output:
Requirement already satisfied: pywhatkit in /usr/local/lib/python3.7/dist-packages (5.3)
Requirement already satisfied: wikipedia in /usr/local/lib/python3.7/dist-packages (from pywhatkit) (1.4.0)
Requirement already satisfied: pyautogui in /usr/local/lib/python3.7/dist-packages (from pywhatkit) (0.9.53)
Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from pywhatkit) (2.23.0)
Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from pywhatkit) (7.1.2)
Requirement already satisfied: mouseinfo in /usr/local/lib/python3.7/dist-packages (from pyautogui->pywhatkit) (0.1.3)
Requirement already satisfied: pyscreeze>=0.1.21 in /usr/local/lib/python3.7/dist-packages (from pyautogui->pywhatkit) (0.1.28)
Requirement already satisfied: pygetwindow>=0.0.5 in /usr/local/lib/python3.7/dist-packages (from pyautogui->pywhatkit) (0.0.9)
Requirement already satisfied: PyTweening>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from pyautogui->pywhatkit) (1.0.4)
Requirement already satisfied: python3-Xlib in /usr/local/lib/python3.7/dist-packages (from pyautogui->pywhatkit) (0.15)
Requirement already satisfied: pymsgbox in /usr/local/lib/python3.7/dist-packages (from pyautogui->pywhatkit) (1.0.9)
Requirement already satisfied: pyrect in /usr/local/lib/python3.7/dist-packages (from pygetwindow>=0.0.5->pyautogui->pywhatkit) (0.2.0)
Requirement already satisfied: pyperclip in /usr/local/lib/python3.7/dist-packages (from mouseinfo->pyautogui->pywhatkit) (1.8.2)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->pywhatkit) (2021.10.8)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->pywhatkit) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->pywhatkit) (2.10)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->pywhatkit) (1.24.3)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.7/dist-packages (from wikipedia->pywhatkit) (4.6.3)
I have also tried to see if pip list has it installed and it says it has:
pip list
Output:
....
....
pywhatkit 5.3
....
....
When I try to import it shows error.
import pywhatkit
Output:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-16-54f6f476dc6e> in <module>()
----> 1 import pywhatkit
4 frames
/usr/lib/python3.7/os.py in __getitem__(self, key)
679 except KeyError:
680 # raise KeyError with the original key value
--> 681 raise KeyError(key) from None
682 return self.decodevalue(value)
683
KeyError: 'DISPLAY'
What is the workaround or solution to this problem?

HuggingFace - 'optimum' ModuleNotFoundError

I want to run the 3 code snippets from this webpage.
I've made all 3 one post, as I am assuming it all stems from the same problem of optimum not having been imported correctly?
Kernel: conda_pytorch_p36
Installations:
pip install optimum
OR
! pip install datasets transformers optimum[intel]
Both provide same Traceback:
Requirement already satisfied: optimum in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (0.1.3)
Requirement already satisfied: transformers>=4.12.0 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (4.15.0)
Requirement already satisfied: coloredlogs in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (15.0.1)
Requirement already satisfied: torch>=1.9 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (1.10.1)
Requirement already satisfied: sympy in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from optimum) (1.8)
Requirement already satisfied: typing-extensions in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from torch>=1.9->optimum) (3.10.0.0)
Requirement already satisfied: dataclasses in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from torch>=1.9->optimum) (0.8)
Requirement already satisfied: numpy>=1.17 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (1.19.5)
Requirement already satisfied: packaging>=20.0 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (21.3)
Requirement already satisfied: pyyaml>=5.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (5.4.1)
Requirement already satisfied: sacremoses in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (0.0.46)
Requirement already satisfied: tqdm>=4.27 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (4.62.3)
Requirement already satisfied: regex!=2019.12.17 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (2021.4.4)
Requirement already satisfied: requests in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (2.25.1)
Requirement already satisfied: huggingface-hub<1.0,>=0.1.0 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (0.2.1)
Requirement already satisfied: tokenizers<0.11,>=0.10.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (0.10.3)
Requirement already satisfied: importlib-metadata in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (4.5.0)
Requirement already satisfied: filelock in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from transformers>=4.12.0->optimum) (3.0.12)
Requirement already satisfied: humanfriendly>=9.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from coloredlogs->optimum) (10.0)
Requirement already satisfied: mpmath>=0.19 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sympy->optimum) (1.2.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from packaging>=20.0->transformers>=4.12.0->optimum) (2.4.7)
Requirement already satisfied: zipp>=0.5 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from importlib-metadata->transformers>=4.12.0->optimum) (3.4.1)
Requirement already satisfied: idna<3,>=2.5 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (2021.5.30)
Requirement already satisfied: chardet<5,>=3.0.2 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from requests->transformers>=4.12.0->optimum) (1.26.5)
Requirement already satisfied: joblib in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sacremoses->transformers>=4.12.0->optimum) (1.0.1)
Requirement already satisfied: click in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sacremoses->transformers>=4.12.0->optimum) (8.0.1)
Requirement already satisfied: six in /home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages (from sacremoses->transformers>=4.12.0->optimum) (1.16.0)
Note: you may need to restart the kernel to use updated packages.
from optimum.intel.lpot.quantization import LpotQuantizerForSequenceClassification
# Create quantizer from config
quantizer = LpotQuantizerForSequenceClassification.from_config(
"echarlaix/quantize-dynamic-test",
"quantization.yml",
model_name_or_path="textattack/bert-base-uncased-SST-2",
)
model = quantizer.fit_dynamic()
Traceback:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-9dcf25f181ea> in <module>
----> 1 from optimum.intel.lpot.quantization import LpotQuantizerForSequenceClassification
2
3 # Create quantizer from config
4 quantizer = LpotQuantizerForSequenceClassification.from_config(
5 "echarlaix/quantize-dynamic-test",
ModuleNotFoundError: No module named 'optimum.intel.lpot'
from optimum.intel.lpot.pruning import LpotPrunerForSequenceClassification
# Create pruner from config
pruner = LpotPrunerForSequenceClassification.from_config(
"echarlaix/magnitude-pruning-test",
"prune.yml",
model_name_or_path="textattack/bert-base-uncased-SST-2",
)
model = pruner.fit()
Traceback:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-e9872c164aee> in <module>
----> 1 from optimum.intel.lpot.pruning import LpotPrunerForSequenceClassification
2
3 # Create pruner from config
4 pruner = LpotPrunerForSequenceClassification.from_config(
5 "echarlaix/magnitude-pruning-test",
ModuleNotFoundError: No module named 'optimum.intel.lpot'
from optimum.graphcore import IPUTrainer
from optimum.graphcore.bert import BertIPUConfig
from transformers import BertForMaskedLM, BertTokenizer
from poptorch.optim import AdamW
# Allocate model and tokenizer as usual
tokenizer = BertTokenizer.from_pretrained("bert-base-cased")
model = BertForMaskedLM.from_pretrained("bert-base-cased")
# Trainer + poptorch custom configuration optional
ipu_config = BertIPUConfig()
trainer = IPUTrainer(model, trainings_args, config=ipu_config)
optimizer = AdamW(model.parameters)
# This is hidden from the user, it will be handled by the Trainer
with trainer.compile(some_data_loader) as model_f:
for steps in range(10): # !
outputs = trainer.step(optimizer)
# Save the model and/or push to hub
model.save_pretrained("...")
model.push_to_hub("...")
Traceback:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-921e03245390> in <module>
----> 1 from optimum.graphcore import IPUTrainer
2 from optimum.graphcore.bert import BertIPUConfig
3 from transformers import BertForMaskedLM, BertTokenizer
4 from poptorch.optim import AdamW
5
ModuleNotFoundError: No module named 'optimum.graphcore'
Please let me know if there's anything else I can add to post.
Pointed out by a Contributor of HuggingFace, on this Git Issue,
The library previously named LPOT has been renamed to Intel Neural Compressor (INC), which resulted in a change in the name of our subpackage from lpot to neural_compressor.
The correct way to import would now be from optimum.intel.neural_compressor.quantization import IncQuantizerForSequenceClassification
Concerning the graphcore subpackage, you need to install it first with pip install optimum[graphcore]
Furthermore you'll need to have access to an IPU in order to use it.
Solution
! pip install datasets transformers optimum[graphcore]
Instead of:
from optimum.intel.lpot.quantization import LpotQuantizerForSequenceClassification
from optimum.intel.lpot.pruning import LpotPrunerForSequenceClassification
from optimum.intel.neural_compressor.quantization import IncQuantizerForSequenceClassification
from optimum.intel.neural_compressor.pruning import IncPrunerForSequenceClassification

EasyOCR Module Not Found Error Despite Successful Install

I'm trying to run a python file that utilizes easyocr but despite a successful install, I can't get it to recognize that I have easyocr installed. Does anyone know why that is?
Please see below for the install and response in Anaconda:
(base) C:\Users\[username]\Desktop >pip install easyocr
Collecting easyocr
Using cached easyocr-1.4.1-py3-none-any.whl (63.6 MB)
Requirement already satisfied: Pillow<8.3.0 in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (8.2.0)
Requirement already satisfied: numpy in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (1.19.2)
Requirement already satisfied: scipy in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (1.6.2)
Requirement already satisfied: opencv-python-headless in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (4.5.1.48)
Requirement already satisfied: python-bidi in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (0.4.2)
Requirement already satisfied: torch in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (1.8.1)
Requirement already satisfied: torchvision>=0.5 in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (0.9.1)
Requirement already satisfied: scikit-image in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (0.18.1)
Requirement already satisfied: PyYAML in c:\users\[username]\anaconda3\lib\site-packages (from easyocr) (5.4.1)
Requirement already satisfied: typing-extensions in c:\users\[username]\anaconda3\lib\site-packages (from torch->easyocr) (3.7.4.3)
Requirement already satisfied: six in c:\users\[username]\anaconda3\lib\site-packages (from python-bidi->easyocr) (1.15.0)
Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in c:\users\[username]\anaconda3\lib\site-packages (from scikit-image->easyocr) (3.4.1)
Requirement already satisfied: networkx>=2.0 in c:\users\[username]\anaconda3\lib\site-packages (from scikit-image->easyocr) (2.5.1)
Requirement already satisfied: imageio>=2.3.0 in c:\users\[username]\anaconda3\lib\site-packages (from scikit-image->easyocr) (2.9.0)
Requirement already satisfied: tifffile>=2019.7.26 in c:\users\[username]\anaconda3\lib\site-packages (from scikit-image->easyocr) (2021.4.8)
Requirement already satisfied: PyWavelets>=1.1.1 in c:\users\[username]\anaconda3\lib\site-packages (from scikit-image->easyocr) (1.1.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\[username]\anaconda3\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->easyocr) (1.3.1)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\[username]\anaconda3\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->easyocr) (2.4.7)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\[username]\anaconda3\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->easyocr) (2.8.1)
Requirement already satisfied: cycler>=0.10 in c:\users\[username]\anaconda3\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->easyocr) (0.10.0)
Requirement already satisfied: decorator<5,>=4.3 in c:\users\[username]\anaconda3\lib\site-packages (from networkx>=2.0->scikit-image->easyocr) (4.4.2)
Installing collected packages: easyocr
Successfully installed easyocr-1.4.1
(base) C:\Users\[username]\Desktop\test.py
Traceback (most recent call last):
File "C:\Users\[username]\Desktop\test.py", line 9, in <module>
from ocr import OCR
File "C:\Users\[username]\Desktop\ ocr.py", line 3, in <module>
import easyocr
ModuleNotFoundError: No module named 'easyocr'

Upon importing spacy, I found TypeError

Libraries are installed - not sure why this is throwing an error.
It works on one of my rigs with the same platform - ubuntu 19.10 - python3.8 and the associated libraries in a virtualenv.
I'm going to show you what I see:
Here's im trying to validate spacy -- which fails.
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ python -m spacy validate
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/home/gordon/p3env/lib/python3.8/site-packages/spacy/__init__.py", line 10, in <module>
from thinc.neural.util import prefer_gpu, require_gpu
File "/home/gordon/p3env/lib/python3.8/site-packages/thinc/neural/__init__.py", line 4, in <module>
from ._classes.model import Model # noqa: F401
File "/home/gordon/p3env/lib/python3.8/site-packages/thinc/neural/_classes/model.py", line 7, in <module>
import srsly
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/__init__.py", line 7, in <module>
from ._pickle_api import pickle_dumps, pickle_loads
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/_pickle_api.py", line 4, in <module>
from . import cloudpickle
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/cloudpickle/__init__.py", line 1, in <module>
from .cloudpickle import *
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/cloudpickle/cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/cloudpickle/cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ ^C
So I just try to install some of those libraries which turn out to be present. - I know everything I need is installed --
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ pip install thinc
Requirement already satisfied: thinc in /home/gordon/p3env/lib/python3.8/site-packages (7.1.1)
Requirement already satisfied: plac<1.0.0,>=0.9.6 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (0.9.6)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (1.0.2)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (2.0.2)
Requirement already satisfied: numpy>=1.7.0 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (1.17.3)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (0.4.1)
Requirement already satisfied: srsly<1.1.0,>=0.0.6 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (0.1.0)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (4.36.1)
Requirement already satisfied: wasabi<1.1.0,>=0.0.9 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (0.3.0)
Requirement already satisfied: preshed<3.1.0,>=1.0.1 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc) (3.0.2)
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ pip install cloudpickle
Requirement already satisfied: cloudpickle in /home/gordon/p3env/lib/python3.8/site-packages (1.2.2)
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ pip install srsly
Requirement already satisfied: srsly in /home/gordon/p3env/lib/python3.8/site-packages (0.1.0)
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ pip install spacy
Requirement already satisfied: spacy in /home/gordon/p3env/lib/python3.8/site-packages (2.2.1)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (3.0.2)
Requirement already satisfied: numpy>=1.15.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (1.17.3)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (2.22.0)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.4.1)
Requirement already satisfied: srsly<1.1.0,>=0.1.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.1.0)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (1.0.2)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (2.0.2)
Requirement already satisfied: thinc<7.2.0,>=7.1.1 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (7.1.1)
Requirement already satisfied: wasabi<1.1.0,>=0.2.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.3.0)
Requirement already satisfied: plac<1.0.0,>=0.9.6 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.9.6)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (1.25.6)
Requirement already satisfied: idna<2.9,>=2.5 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2019.9.11)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc<7.2.0,>=7.1.1->spacy) (4.36.1)
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ pip uninstall spacy
Uninstalling spacy-2.2.1:
Would remove:
/home/gordon/p3env/bin/spacy
/home/gordon/p3env/lib/python3.8/site-packages/bin/*
/home/gordon/p3env/lib/python3.8/site-packages/spacy-2.2.1.dist-info/*
/home/gordon/p3env/lib/python3.8/site-packages/spacy/*
Proceed (y/n)? y
Successfully uninstalled spacy-2.2.1
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ pip install spacy
Processing /home/gordon/snap/code/common/.cache/pip/wheels/1d/22/2b/2d5d8fe5e5fe728a766158a89d017051c19005bb7aabc1d79a/spacy-2.2.1-cp38-cp38-linux_x86_64.whl
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (1.0.2)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.4.1)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (3.0.2)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (2.22.0)
Requirement already satisfied: srsly<1.1.0,>=0.1.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.1.0)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (2.0.2)
Requirement already satisfied: plac<1.0.0,>=0.9.6 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.9.6)
Requirement already satisfied: thinc<7.2.0,>=7.1.1 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (7.1.1)
Requirement already satisfied: wasabi<1.1.0,>=0.2.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (0.3.0)
Requirement already satisfied: numpy>=1.15.0 in /home/gordon/p3env/lib/python3.8/site-packages (from spacy) (1.17.3)
Requirement already satisfied: certifi>=2017.4.17 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (1.25.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /home/gordon/p3env/lib/python3.8/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2.8)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in /home/gordon/p3env/lib/python3.8/site-packages (from thinc<7.2.0,>=7.1.1->spacy) (4.36.1)
Installing collected packages: spacy
Successfully installed spacy-2.2.1
RIGHT HERE -- I just try importing spacy and this is what I'm getting on one of the machines... while the other works -- odd I'll need to look into this -
Has anyone run into this ?
(p3env) gordon#citadel:~/p3env/alice/alice/spiders$ python
Python 3.8.0 (default, Oct 15 2019, 09:10:20)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gordon/p3env/lib/python3.8/site-packages/spacy/__init__.py", line 10, in <module>
from thinc.neural.util import prefer_gpu, require_gpu
File "/home/gordon/p3env/lib/python3.8/site-packages/thinc/neural/__init__.py", line 4, in <module>
from ._classes.model import Model # noqa: F401
File "/home/gordon/p3env/lib/python3.8/site-packages/thinc/neural/_classes/model.py", line 7, in <module>
import srsly
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/__init__.py", line 7, in <module>
from ._pickle_api import pickle_dumps, pickle_loads
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/_pickle_api.py", line 4, in <module>
from . import cloudpickle
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/cloudpickle/__init__.py", line 1, in <module>
from .cloudpickle import *
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/cloudpickle/cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "/home/gordon/p3env/lib/python3.8/site-packages/srsly/cloudpickle/cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes
I don't believe this happens outside of the virtualenv.
Let me know if you have seen this one, when I fix it I'll update the post.
$ python3.8 -m pip install srsly --upgrade
Defaulting to user installation because normal site-packages is not writeable
Collecting srsly
Downloading srsly-2.0.0-cp38-cp38-manylinux1_x86_64.whl (311 kB)
|████████████████████████████████| 311 kB 1.3 MB/s
ERROR: thinc 7.3.1 has requirement srsly<1.1.0,>=0.0.6, but you'll have srsly 2.0.0 which is incompatible.
ERROR: spacy 2.2.3 has requirement srsly<1.1.0,>=0.1.0, but you'll have srsly 2.0.0 which is incompatible.
Installing collected packages: srsly
Attempting uninstall: srsly
Found existing installation: srsly 0.1.0
Uninstalling srsly-0.1.0:
Successfully uninstalled srsly-0.1.0
Successfully installed srsly-2.0.0
You might want to use python3.8 -m pip install srsly==1.0.1.

Categories