Important: Please read the Qt Code of Conduct -

PyQt and Pylupdate5

  • Re: Translation using PyQt and Pylupdate5

    I am trying to create a translation file:

    pylupdate5.py3 untitled.ui -ts zh_FN.ts

    I get an error:

    Traceback (most recent call last):
      File "/usr/lib64/python3.7/", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib64/python3.7/", line 85, in _run_code
        exec(code, run_globals)
      File "/usr/lib64/python3/site-packages/PyQt5/", line 239, in <module>
      File "/usr/lib64/python3/site-packages/PyQt5/", line 228, in main
        defaultContext, True)
    UnicodeEncodeError: 'latin-1' codec can't encode characters in position 12-21: ordinal not in range(256)

    For the test, I made an empty ui in Designer.
    Wrong encoding again.

    OS Linux
    python 3.7.4
    python3-module-PyQt5 5.11.3

    I am new to Python.
    Sorry if the question is stupid.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you show the content of your .ui file ?

  • @SGaist said in PyQt and Pylupdate5:

    Can you show the content of your .ui file ?

    A practically empty sample.

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <widget class="QMainWindow" name="MainWindow">
      <property name="geometry">
      <property name="windowTitle">
      <widget class="QWidget" name="centralwidget">
       <layout class="QGridLayout" name="gridLayout">
        <item row="0" column="0" colspan="3">
         <widget class="QTextEdit" name="textEdit">
          <property name="html">
           <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;;&gt;
    &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    p, li { white-space: pre-wrap; }
    &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
    &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Hi, I'm Zhenya.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
        <item row="1" column="0">
         <widget class="QPushButton" name="pushButton">
          <property name="text">
        <item row="1" column="1">
         <spacer name="horizontalSpacer">
          <property name="orientation">
          <property name="sizeHint" stdset="0">
        <item row="1" column="2">
         <widget class="QPushButton" name="pushButton_2">
          <property name="text">
      <widget class="QStatusBar" name="statusbar"/>

  • Answer.
    The path must not contain non-ascii characters.

  • Lifetime Qt Champion

    Do you mean the path to the file ?

Log in to reply