TypeError: 'NoneType' object is not iterable still present in latest release #14553
Replies: 3 comments 1 reply
-
The issue you are encountering, where a Cause of the IssueThe root cause of the issue is that the The problematic code snippet (as highlighted in the issue report) is: if result is not None:
lines = []
for res in result:
for line in res:
logger.info(line)
lines.append(pprint.pformat(line) + "\n") If Status of the FixA fix for this issue was committed to the main branch in June 2024, as noted by SHWL. However, it appears that this fix has not yet been included in the latest official release (October 2024). The delay in releasing this fix could be due to various reasons:
WorkaroundsWhile waiting for the official release that includes the fix, you can consider the following workarounds: 1. Modify the Installed CodeIf you are comfortable editing the installed library, you can manually apply the fix to handle the if result:
lines = []
for res in result:
for line in res:
logger.info(line)
lines.append(pprint.pformat(line) + "\n")
else:
logger.info("No text detected in the image.") This ensures that the script will not attempt to iterate over 2. Use the Main BranchIf you need the fix immediately, you can install PaddleOCR directly from the main branch on GitHub, which should include the changes: pip install --upgrade git+https://github.com/PaddlePaddle/PaddleOCR.git This will replace your current installation with the latest development version. 3. Use a Python Script with Error HandlingAs you mentioned, running PaddleOCR via a Python script with a from paddleocr import PaddleOCR
ocr = PaddleOCR()
result = ocr.ocr('path_to_image.jpg')
if result:
for res in result:
print(res)
else:
print("No text detected in the image.") 4. Wait for the Next ReleaseIf you prefer not to modify the code or use the main branch, you can wait for the next release. It is recommended to monitor the releases page for updates. Next Steps and Recommendations
If you encounter further issues or have additional concerns, feel free to ask! Response generated by feifei-bot | chatgpt-4o-latest |
Beta Was this translation helpful? Give feedback.
-
Could you provide the reproduce code? I will trace it. |
Beta Was this translation helpful? Give feedback.
-
The auto generated answer was actually helpful to some extent. The actual fix seems to be the PR #14132, merged on October 31st 2024. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
first of all thank you for your work.
I'm having one issue though. When running paddleocr from the command line on an image where there is no text present it errors out. This is an issue that was already more than once reported, for example in #11203. This bug is really annoying because it prevents running paddleocr on a whole folder via command line.
SHWL mentioned that this bug was fixed in the main branch in june, but in the latest release from october this bug is still present. Can you give my any update when this will be fixed with a new release?
I know this can be prevented when running paddleocr via a python script and using a try-catch block but this is not what i would like to do.
Beta Was this translation helpful? Give feedback.
All reactions