I’m working on a project where I want to integrate a captcha-bypassing feature. I’ve been using the 2captcha service for this and it was quite successful until I switched from Windows to Linux (Ubuntu 22.04).
I keep receiving the same error – ‘TwoCaptcha’ object has no attribute ‘normal’ when I try to run this function:
def solve_captcha(image_path):
solver = TwoCaptcha(api_key)
try:
result = solver.normal(image_path)
except Exception as e:
logging.error(e)
else:
return result['code']
The problem is, that I have the same library version installed on both systems. I didn’t change anything in the function code above after transitioning, and official documentation includes said attribute in its examples.
Can anyone help me understand the issue?
I’ve tried to search both: library documentation (https://pypi.org/project/2captcha-python/), as well as examples on the official service’s webpage (https://2captcha.com/api-docs/normal-captcha), but they both include ‘normal’ attributes in their codes.
2
Answers
So... Found the problem and shearing the solution for people like me:
Apparently, I've been using a deprecated version of 2capltcha's dependency (called 'TwoCaptcha').
The active one is called '2captcha-python'.
The deprecated one just didn't have the needed functionality
Good afternoon, try running the code using the
python3
command.Example:
python3 main.py
Or use a virtual environment.