How to resolve "AttributeError: 'HandDetector' object has no attribute 'findPosition'"? - python

I am getting an error:
Traceback (most recent call last):
File "d:\buh\DynamicTextReader.py", line 68, in <module>
lmList, bboxInfo = detector.findPosition(img)
AttributeError: 'HandDetector' object has no attribute 'findPosition'
When running the program:
import cv2
from cvzone.HandTrackingModule import HandDetector
from time import sleep
import numpy as np
import cvzone
from pynput.keyboard import Controller
lmList, bboxInfo = detector.findPosition(img) # The Error Is In This Line
img = drawAll(img, buttonList)
(I removed many parts of the code)
My python version is 3.9.0.
I tried to change the versions of cvzone but the error couldn't resolve.

Related

Why does lottie throw ImportError: cannot import name 'PngRenderer' from 'lottie.exporters.cairo'?

Why does lottie give the error ImportError: cannot import name 'PngRenderer' from 'lottie.exporters.cairo'?
import lottie
from lottie.exporters.gif import export_gif
from lottie.parsers.tgs import parse_tgs
def convert_tgs_to_gif(tgs_file, gif_file):
try:
animation = parse_tgs(tgs_file)
export_gif(animation, gif_file, skip_frames=5, dpi=48)
return True
except Exception:
logging.exception("Error occurred while converting TGS to GIF.")
return False
Traceback errors:
Traceback (most recent call last):
File "C:\Users\Bubunduc\PycharmProjects\tg\main.py", line 11, in <module>
from lottie.exporters.gif import export_gif
File "C:\Users\Bubunduc\PycharmProjects\tg\venv\lib\site-packages\lottie\exporters\gif.py", line 5, in <module>
from .cairo import PngRenderer
ImportError: cannot import name 'PngRenderer' from 'lottie.exporters.cairo' (C:\Users\Bubunduc\PycharmProjects\tg\venv\lib\site-packages\lottie\exporters\cairo.py)
I tried to import this library in different ways, tried to understand the source code
Here the problem is in a completely different library. PngRenderer requires the cairosvg library. On windows, it requires libcairo-2.dll. Therefore, the solution to this problem is the correct installation of cairosvg.
Answer about installing cairosvg on windows.

AttributeError: 'SearchEngine' object has no attribute 'ses'

I am trying to use the zipcodes package but was getting a ses error. Here is a brief snippt of my code.
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
import geopandas as gpd
import requests
import zipfile
import io
import os
import pyproj
from shapely.ops import transform
from functools import partial
import json
from uszipcode import SearchEngine
search = SearchEngine(simple_zipcode=True)
I am getting the following error
Exception ignored in: <function SearchEngine.__del__ at 0x7fcd6087eca0>
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/uszipcode/search.py", line 195, in __del__
if self.ses:
AttributeError: 'SearchEngine' object has no attribute 'ses'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-35-325ac6f8df7d> in <module>
----> 1 search = SearchEngine(simple_zipcode=True)
2 search.ses.scalar(SimpleZipcode)
TypeError: __init__() got an unexpected keyword argument 'simple_zipcode'
Any pointers?

module 'pytesseract' has no attribute 'image_to_string'

I've been trying to solve this error for a long time. I have googled this error and find nothing to solve it.
error
Traceback (most recent call last):
File "tess.py", line 6, in <module>
print(pytesseract.image_to_string(Image.open(image_file)))
AttributeError: module 'pytesseract' has no attribute 'image_to_string'
Please also tell me, What would be the "pytesseract.pytesseract.tesseract_cmd = 'System_path_to_tesseract'" for ubuntu
code
from PIL import Image
from pytesseract import *
import pytesseract
image_file = '4.jpg'
print(pytesseract.image_to_string(Image.open(image_file)))
Help me to solve this error
Thanks in advance

AttributeError: partially initialized module 'cv2' has no attribute 'imread'

Till 1 hour back my opencv code was working perfectly fine. it could run my script without error. but I don't know why some time back suddenly it started giving me this error:
AttributeError: partially initialized module 'cv2' has no attribute 'imread' (most likely due to a circular import)
Traceback (most recent call last):
File "FACEDETECTION.PY", line 1, in <module>
import cv2
File "C:\Users\Lenovo\anaconda3\envs\CAM\lib\site-packages\cv2\__init__.py", line 5, in <module>
from .cv2 import *
ImportError: numpy.core.multiarray failed to import
So what could be the error?
update: Here is my code-
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = "C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe"
path = "text.png"
img = cv2.imread(path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
text = pytesseract.image_to_string(img)
print(text)
cv2.imshow("name", img)
cv2.waitKey(7000)

AttributeError: '_process_plot_var_args' object has no attribute 'get_next_color'

I have tried to run the following code. but it gives an argument required error in lifelines/plotting.py file. i can't fix it .
import pandas as pd
from lifelines.datasets import load_dd
import matplotlib.pyplot as plt
data = load_dd()
print data.sample(6)
from lifelines import KaplanMeierFitter
kmf = KaplanMeierFitter()
T = data["duration"]
E = data["observed"]
kmf.fit(T, event_observed=E)
kmf.survival_function_.plot()
plt.title('Survival function of political regimes');
kmf.plot()
plt.show()
but it gives the following error
Traceback (most recent call last): File "/Users/rabindra/PycharmProjects/SurvivalAnalysis/sources/main.py", line 17, in <module>
kmf.plot() File "/Library/Python/2.7/site-packages/lifelines/plotting.py", line 331, in plot
set_kwargs_color(kwargs) File "/Library/Python/2.7/site-packages/lifelines/plotting.py", line 223, in set_kwargs_color
kwargs["ax"]._get_lines.get_next_color()) AttributeError: '_process_plot_var_args' object has no attribute 'get_next_color'
I was facing the same issue.
Upgraded lifelines to 0.14.0 and matplotlib to 2.2.2 and it works.

Categories