Hi Andrea,

Thanks for your help.

Effectively it is part of the answer I am looking for.  But my problem is
"higher" in the python settings for QGIS. If I write 'sys.stdout.encoding =
"utf-8"' to the console, my plugin will be loaded without problem. I am
developing a plugin whit "from ultralytics import YOLO" and I am receiving
the following message :

           File
"C:\Users\pierr\AppData\Roaming\Python\Python39\site-packages\ultralytics\ut
ils\__init__.py", line 238, in set_logging
             if WINDOWS and sys.stdout.encoding != "utf-8":
            AttributeError: 'NoneType' object has no attribute 'encoding' 

Ultralytics YOLO needs an encoding attribute for "sys.stdout" to be
imported. I didn't find any solution to set the encoding attribute with the
startup.py file.


Regards,

Pierre










-----Message d'origine-----
De : QGIS-User <qgis-user-boun...@lists.osgeo.org> De la part de Andrea
Giudiceandrea via QGIS-User
Envoyé : 8 avril 2024 07:21
À : qgis-user@lists.osgeo.org
Objet : Re: [Qgis-user] Python console sys.stdout.encoding

> Why with the python shell it is possible to ask what is the value of
sys.stdout.encoding but this value does not exist in the python console of
Qgis ?

Hi Pierre,
I think it's very likely due to:

https://github.com/qgis/QGIS/blob/35aadbc18a2245fce299a3597137c8d9b7f048b0/p
ython/console/console_output.py#L139

         sys.stdout = writeOut(self, sys.stdout)

In the Python console, sys.stdout is a <class
'console.console_output.writeOut'> object which doesn't have an "encoding"
attribute.

Best regards.

Andrea
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to