树莓派4 ubuntu20.04安装PyInstaller

1、正常情况下,我们是通过pip3来安装PyInstaller,但是在树莓派的ubuntu20.04上安装时,会报错如下:

In function ‘strncpy’,
      inlined from ‘splitName’ at ../../src/pyi_launch.c:83:5,
      inlined from ‘_extract_dependency’ at ../../src/pyi_launch.c:215:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4097 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_utils.c:60:
  In function ‘strncpy’,
      inlined from ‘pyi_open_target’ at ../../src/pyi_utils.c:561:5:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncpy’,
      inlined from ‘pyi_open_target’ at ../../src/pyi_utils.c:562:5:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_pythonlib.c:39:
  In function ‘strncpy’,
      inlined from ‘pyi_pylib_start_python’ at ../../src/pyi_pythonlib.c:487:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncat’,
      inlined from ‘pyi_pylib_start_python’ at ../../src/pyi_pythonlib.c:491:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin___strncat_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../src/pyi_pythonlib.c: In function ‘pyi_pylib_start_python’:
  ../../src/pyi_pythonlib.c:491:9: note: length computed here
    491 |         strncat(pypath, status->mainpath, strlen(status->mainpath));
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_pythonlib.c:39:
  In function ‘strncpy’,
      inlined from ‘pyi_pylib_start_python’ at ../../src/pyi_pythonlib.c:483:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_path.c:38:
  In function ‘strncpy’,
      inlined from ‘pyi_path_join’ at ../../src/pyi_path.c:146:5:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../src/pyi_path.c: In function ‘pyi_path_join’:
  ../../src/pyi_path.c:146:5: note: length computed here
    146 |     strncpy(result, path1, strlen(path1));
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_path.c:38:
  In function ‘strncat’,
      inlined from ‘pyi_path_join’ at ../../src/pyi_path.c:159:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
    136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../src/pyi_path.c: In function ‘pyi_path_join’:
  ../../src/pyi_path.c:155:11: note: length computed here
    155 |     len = strlen(path2);
        |           ^~~~~~~~~~~~~
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_path.c:38:
  In function ‘strncpy’,
      inlined from ‘pyi_search_path’ at ../../src/pyi_path.c:256:13:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output may be truncated copying 4096 bytes from a string of length 4096 [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncpy’,
      inlined from ‘pyi_path_executable’ at ../../src/pyi_path.c:331:13:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  Waf: Leaving directory `/tmp/pip-install-1jgb0leb/pyinstaller/bootloader/build/debug'
  Build failed
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)

2、通过错误提示,我们可以分析出来,这里报的错误为Werror,即在用gcc编译时,将警告信息当作错误来处理,并不是真的时运行不下去,所以,我们要做的就是修改makefile,让使用gcc编译的时候,不进行Werror处理;

3、我们从pip官网下载pyinstaller源码

 https://pypi.org/project/PyInstaller/

4、将源码解压,打开,尝试直接运行python3 setup.py install ,依旧会报上面的错误,现在重点来了,修改make文件,这里这个make文件也找到了好半天才找到

//进入pyinstaller源码下面的bootloader文件夹

cd bootloader

//编辑make文件,这里是wscript

vim wscript

//通过/Werror查找,我们可以找到在第461,gcc的参数里面有Werror这个参数,直接删除这一行参数就行,注意只删除‘-Werror’这一句

//保存退出,返回pyinstaller的根目录

//安装就可以了
python3 setup.py install

OK,至此pyinstaller就安装完成了,可以使用他来发布你的QT程序了 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章