Unable to find image

Hi all,

I’m having a problem to find any kind of image, I was able to setup the city bot on two different environments but in both of them I get the same error, when trying to find an image, regardless the image. Follows the error below (using Python):

Traceback (most recent call last):
File “C:/Users/Lucas Camilote/PycharmProjects/checklisttotvs/bot/bot/bot.py”, line 59, in
Bot.main()
File “C:\Users\Lucas Camilote\AppData\Local\Programs\Python\Python38\lib\site-packages\botcity\base\bot.py”, line 142, in main
bot.action(execution)
File “C:/Users/Lucas Camilote/PycharmProjects/checklisttotvs/bot/bot/bot.py”, line 38, in action
if not self.find( “search”, matching=0.97, waiting_time=10000):
File “C:\Users\Lucas Camilote\AppData\Local\Programs\Python\Python38\lib\site-packages\botcity\core\bot.py”, line 275, in find_until
if is_retina():
File “C:\Users\Lucas Camilote\AppData\Local\Programs\Python\Python38\lib\site-packages\botcity\base\utils.py”, line 29, in is_retina
return retina
UnboundLocalError: local variable ‘retina’ referenced before assignment

Process finished with exit code 1

Can you please help me with it?

@lcamilote I was able to detect the issue here and I will submit a fix for the framework.
I will post a new message here once it is available.

That’s great, I really appreciate, thank you for your help.

@lcamilote I just released a new version of botcity-framework-base with the fix.
Could you please try to install it with:

pip install botcity-framework-base==0.3.1
1 Like

You’re awesome man, it’s working now!

Thank you!

1 Like

That is great news! Sorry for the bug that ended up passing by! :smiley:
I’m glad it is working now. Feel free to send a new message if you find other issues.

Hey man,

I don’t know if I have to create a new post, but I’ve installed the bot Studio on a new environment, and this one has Python 3.9.13 installed, when I try to click on a image from this one, I get the following error:

Traceback (most recent call last):
File “C:\Users\Administrator\PycharmProjects\checklist\totvschecklist\totvschecklist\bot.py”, line 38, in
Bot.main()
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\botcity\base\bot.py”, line 142, in main
bot.action(execution)
File “C:\Users\Administrator\PycharmProjects\checklist\totvschecklist\totvschecklist\bot.py”, line 25, in action
if not self.find( “oamp”, matching=0.97, waiting_time=10000):
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\botcity\core\bot.py”, line 272, in find_until
ele = pyautogui.locateOnScreen(element_path, region=region, confidence=matching,
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\pyautogui_init_.py”, line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\pyautogui_init_.py”, line 213, in locateOnScreen
return pyscreeze.locateOnScreen(*args, **kwargs)
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\pyscreeze_init_.py”, line 372, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\pyscreeze_init_.py”, line 352, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File “C:\Users\Administrator\PycharmProjects\checklist\venv\lib\site-packages\pyscreeze_init_.py”, line 252, in _locateAll_python
raise NotImplementedError(‘The confidence keyword argument is only available if OpenCV is installed.’)
NotImplementedError: The confidence keyword argument is only available if OpenCV is installed.

Would you be able to take a look on this one? Please

1 Like

Hi @lcamilote,

It might indicate OpenCV is missing. Try running pip install opencv-python and then execute your bot again.

Hi Jamaral,

I noticed that, and already tried to install the package, but I receive the message “Requirement already satisfied” and when I try to find an image I get the same error anyway.

pip install opencv:
(venv) PS C:\Users\Administrator\PycharmProjects\checklist> pip install opencv-python
Requirement already satisfied: opencv-python in c:\users\administrator\pycharmprojects\checklist\venv\lib\site-packages (4.6.0.66)
Requirement already satisfied: numpy>=1.19.3 in c:\users\administrator\pycharmprojects\checklist\venv\lib\site-packages (from opencv-python) (1.23.1)

I have installed the same Python version (3.10.4) as I have installed in another environment (and it works) and now I’m receiving the following error:

Traceback (most recent call last):
File “C:\Users\Administrator\PycharmProjects\checklist2\dailychecklist\dailychecklist\bot.py”, line 23, in
from botcity.core import DesktopBot
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\botcity\core_init_.py”, line 1, in
from .bot import * # noqa: F401, F403
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\botcity\core\bot.py”, line 16, in
from . import config, cv2find, os_compat
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\botcity\core\cv2find.py”, line 34, in
import cv2
ImportError: DLL load failed while importing cv2: The specified module could not be found.

Anyone know how should I proceed to resolve it?

Thank you all!

Hi @lcamilote!

I was doing some research and it seems to be a problem that can be caused by many different reasons. Could you downgrade the installed version of open-cv just to test if the behavior is the same?

Something like:
pip install opencv-python=3.3.0.9

I used this thread’s answer as a reference: python - "DLL load failed" when import cv2 (opencv) - Stack Overflow

Hi Joao,

I found a solution for my environment, the issue (apparently) was running the bot Studio on Windows Server 2012 R2, so I had to install a feature (Desktop Experience) on my Windows Server and it worked, follow the link I used as a reference:

Thank you all!

2 Likes