Skip to content

Build Failure on Windows, Python 3.6 GCC Compilers: UnicodeDecodeError. #16668

Closed

Description

@Qiyu8

updating to the latest master , an UnicodeDecodeError occurred even after execute git clean -xfd

Reproducing code example:

No code example.

Error message:

CCompilerOpt.cc_test_flags[989] : testing flags (/WX)
CCompilerOpt.__init__[1137] : feature 'AVX512_KNL' is disabled, MSVC compiler doesn't support it
CCompilerOpt.__init__[1137] : feature 'AVX512_KNM' is disabled, MSVC compiler doesn't support it
CCompilerOpt.__init__[1621] : check requested baseline
CCompilerOpt.cc_test_flags[989] : testing flags (/arch:SSE)
Traceback (most recent call last):
  File "setup.py", line 499, in <module>
    setup_package()
  File "setup.py", line 491, in setup_package
    setup(**metadata)
  File "D:\Source\numpy\numpy\distutils\core.py", line 169, in setup
    return old_setup(**new_attr)
  File "C:\Python36\lib\site-packages\setuptools\__init__.py", line 143, in setup
    return distutils.core.setup(**attrs)
  File "C:\Python36\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Python36\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Python36\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "D:\Source\numpy\numpy\distutils\command\build_ext.py", line 111, in run
    build_clib.run()
  File "D:\Source\numpy\numpy\distutils\command\build_clib.py", line 126, in run
    cpu_dispatch=self.cpu_dispatch, cache_path=opt_cache_path
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 2451, in new_ccompiler_opt
    opt = CCompilerOpt(compiler, **kwargs)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 2055, in __init__
    _Parse.__init__(self, cpu_baseline, cpu_dispatch)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 1624, in __init__
    baseline_names = self.feature_names(cpu_baseline)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 1182, in feature_names
    if self.feature_is_supported(f, force_flags=force_flags):
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 829, in cache_wrap_me
    ccb = cb(self, *args, **kwargs)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 1471, in feature_is_supported
    if not self.feature_test(impl, force_flags):
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 829, in cache_wrap_me
    ccb = cb(self, *args, **kwargs)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 1432, in feature_test
    force_flags = self.feature_flags(name)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 829, in cache_wrap_me
    ccb = cb(self, *args, **kwargs)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 1411, in feature_flags
    if not f or not self.cc_test_flags(f):
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 829, in cache_wrap_me
    ccb = cb(self, *args, **kwargs)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 991, in cc_test_flags
    test = self.dist_test(test_path, flags)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 556, in dist_test
    [source], flags, output_dir=self.conf_tmp_path
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 536, in dist_compile
    sources, extra_postargs=flags, **kwargs
  File "C:\Python36\lib\distutils\_msvccompiler.py", line 423, in compile
    self.spawn(args)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 668, in _dist_test_spawn_paths
    self._dist_test_spawn(cmd)
  File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 686, in _dist_test_spawn
    o = o.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 4: invalid continuation byte
CCompilerOpt._cache_write[786] : write cache to path -> D:\Source\numpy\build\temp.win-amd64-3.6\ccompiler_opt_cache_clib.py

Activity

  1. mattip commented on Jun 23, 2020

    @mattip
    Member

    Do you have non-ascii characters in your path? Could you stop at the error and try to work out what is going on?

  2. mattip commented on Jun 23, 2020

    @mattip
    Member

    does o have an encoding property o.encoding ?

  3. Qiyu8 commented on Jun 23, 2020

    @Qiyu8
    MemberAuthor

    I'm sure that no non-ascii characters existed, It's seems like the exception is triggered when testing SSE flags:

    CCompilerOpt.cc_test_flags[991] : testing flags (/arch:SSE)
    decode:b'cl: \xc3\xfc\xc1\xee\xd0\xd0 warning D9002 :\xba\xf6\xc2\xd4\xce\xb4\xd6\xaa\xd1\xa1\xcf\xee\xa1\xb0/arch:SSE\xa1\xb1\r\ntest_flags.c\r\n'
    

    o.decode() failed to decode

    b'cl: \xc3\xfc\xc1\xee\xd0\xd0 warning D9002 :\xba\xf6\xc2\xd4\xce\xb4\xd6\xaa\xd1\xa1\xcf\xee\xa1\xb0/arch:SSE\xa1\xb1\r\ntest_flags.c\r\n'
    
  4. eric-wieser commented on Jun 23, 2020

    @eric-wieser
    Member

    @Qiyu8, your compiler output is encoded in GB2312 rather than utf8 it seems. The string decodes to

    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE”
    test_flags.c
    
  5. eric-wieser commented on Jun 23, 2020

    @eric-wieser
    Member

    https://bugs.python.org/issue27179#msg267091 seems slightly related, I haven't read the whole thread.

  6. Qiyu8 commented on Jun 23, 2020

    @Qiyu8
    MemberAuthor

    Maybe a parallel problem, I always build numpy with python setup.py build_ext -i -j 8, turned to python setup.py build_ext -i and the build successfully.

  7. eric-wieser commented on Jun 23, 2020

    @eric-wieser
    Member

    My guess would be that the codepage of the parallel processes does not match the codepage of the parent process.

  8. Qiyu8 commented on Jul 9, 2020

    @Qiyu8
    MemberAuthor

    This problem arose again in my local machine, even with non-parallel build.

  9. mattip commented on Jul 9, 2020

    @mattip
    Member

    There was a long discussion and a PEP 597 about changing the default stdout encoding. Bottom line: what does
    locale.getpreferredencoding() show for you? If you modify the offending line

      File "D:\Source\numpy\numpy\distutils\ccompiler_opt.py", line 686, in _dist_test_spawn
        o = o.decode()
    

    to use that encoding does it fix the problem?

  10. Qiyu8 commented on Jul 9, 2020

    @Qiyu8
    MemberAuthor

    my encoding result is cp936, The build can succeed after modifed to o.decode(encoding="cp936"), But there are large amount of warning D9002 :忽略未知选项“/arch:SSE” produced during build.

  11. Qiyu8 commented on Jul 9, 2020

    @Qiyu8
    MemberAuthor

    @mattip I want to provide a PR to solve this issue, modify decode() to decode(locale.getpreferredencoding()), what do you think?

  12. mattip commented on Jul 9, 2020

    @mattip
    Member

    modify decode() to decode(locale.getpreferredencoding())

    I think the preferred spelling of this is when calling check_output to specify universal_newlines=True which will force the output to be text (already encoded). Search for "unversal_newlines" on the subprocess doc page. Could you try it (since we don't really test for non-ascii windows versions)?

    As for the multiple warnings, can you show the part of the log that looks like the one in this comment ?

  13. Qiyu8 commented on Jul 9, 2020

    @Qiyu8
    MemberAuthor

    The build can succeed after specify universal_newlines=True, see the build log of multiple warnings:

    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE2”
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DHAVE_BLAS_ILP64 -DBLAS_SYMBOL_SUFFIX=64_ -Inumpy\core\include -Inumpy\core\include/numpy -Inumpy\core\src\common -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -IC:\Python36\include -IC:\Python36\include -Inumpy\core\src\common -Inumpy\core\src\npymath -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcnumpy\linalg\lapack_lite\f2c_s_lapack.c /Fobuild\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_s_lapack.obj /arch:SSE2
    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE2”
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DHAVE_BLAS_ILP64 -DBLAS_SYMBOL_SUFFIX=64_ -Inumpy\core\include -Inumpy\core\include/numpy -Inumpy\core\src\common -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -IC:\Python36\include -IC:\Python36\include -Inumpy\core\src\common -Inumpy\core\src\npymath -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcnumpy\linalg\lapack_lite\f2c_lapack.c /Fobuild\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_lapack.obj /arch:SSE2
    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE2”
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DHAVE_BLAS_ILP64 -DBLAS_SYMBOL_SUFFIX=64_ -Inumpy\core\include -Inumpy\core\include/numpy -Inumpy\core\src\common -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -IC:\Python36\include -IC:\Python36\include -Inumpy\core\src\common -Inumpy\core\src\npymath -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcnumpy\linalg\lapack_lite\f2c_blas.c /Fobuild\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_blas.obj /arch:SSE2
    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE2”
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DHAVE_BLAS_ILP64 -DBLAS_SYMBOL_SUFFIX=64_ -Inumpy\core\include -Inumpy\core\include/numpy -Inumpy\core\src\common -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -IC:\Python36\include -IC:\Python36\include -Inumpy\core\src\common -Inumpy\core\src\npymath -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcnumpy\linalg\lapack_lite\f2c_config.c /Fobuild\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_config.obj /arch:SSE2
    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE2”
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DHAVE_BLAS_ILP64 -DBLAS_SYMBOL_SUFFIX=64_ -Inumpy\core\include -Inumpy\core\include/numpy -Inumpy\core\src\common -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -IC:\Python36\include -IC:\Python36\include -Inumpy\core\src\common -Inumpy\core\src\npymath -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcnumpy\linalg\lapack_lite\f2c.c /Fobuild\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c.obj /arch:SSE2
    cl: 命令行 warning D9002 :忽略未知选项“/arch:SSE2”
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Python36\libs /LIBPATH:C:\Python36\PCbuild\amd64 /LIBPATH:build\temp.win-amd64-3.6 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\lib\x64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64 npymath.lib /EXPORT:PyInit__umath_linalg build\temp.win-amd64-3.6\Release\numpy\linalg\umath_linalg.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\python_xerbla.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_z_lapack.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_c_lapack.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_d_lapack.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_s_lapack.obj 
    build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_lapack.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_blas.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c_config.obj build\temp.win-amd64-3.6\Release\numpy\linalg\lapack_lite\f2c.obj /OUT:numpy\linalg\_umath_linalg.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\numpy\linalg\_umath_linalg.cp36-win_amd64.lib
    
  14. mattip commented on Jul 9, 2020

    @mattip
    Member

    Good to hear: so the correct fix for this issue is universal_newlines=True

    As for the warnings: on 64-bit windows, you should not be using /arch:SSE2, since it is on by default. This is a separate issue, @seiko2plus might be able to help.

  15. eric-wieser commented on Jul 9, 2020

    @eric-wieser
    Member

    Note that universal_newlines=True is equivalent to decoding with locale.getpreferredencoding(False) according to https://docs.python.org/3/library/io.html#io.TextIOWrapper.

    I still suspect there's a nastier issue here regarding the locale in which parallel vs non-parallel builds are executed in.

  16. seiko2plus commented on Jul 9, 2020

    @seiko2plus
    Member

    @mattip, This is a separate issue

    yes, my bad. I didn't expect msvc to raise warning messages in another language than English.

    @Qiyu8, well to solve this issue you have to replace:

    "ignoring unknown option|" # msvc

    with:

    "warning D9002|"  # msvc, it should be work with any language. 

    And why?
    Because microsoft and Intel compiler tending to raise warning messages rather than fatal errros for unkown or unsupported options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions