我正在尝试在Mac OS X 10.13.6上构建OpenCV 4.0.0。我从python.org使用python-3.7.2-macosx10.9.pkg
安装了Python 3.7,但出现以下错误:
$ python3 ./build_framework.py ios
Using IPHONEOS_DEPLOYMENT_TARGET=8.0
Using iPhoneOS ARCHS=['armv7', 'armv7s', 'arm64']
Using iPhoneSimulator ARCHS=['i386', 'x86_64']
============================================================
ERROR: cannot use a string pattern on a bytes-like object
============================================================
Traceback (most recent call last):
File "./build_framework.py", line 117, in build
self._build(outdir)
File "./build_framework.py", line 85, in _build
xcode_ver = getXCodeMajor()
File "./build_framework.py", line 45, in getXCodeMajor
m = re.match(r'Xcode\s+(\d+)\..*', ret, flags=re.IGNORECASE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 173, in match
return _compile(pattern, flags).match(string)
TypeError: cannot use a string pattern on a bytes-like object
我首先尝试使用默认的Python版本(2.7.10),但那里也出现错误:
$ python ./build_framework.py ios
Using IPHONEOS_DEPLOYMENT_TARGET=11.0
Using iPhoneOS ARCHS=['armv7', 'armv7s', 'arm64']
Using iPhoneSimulator ARCHS=['i386', 'x86_64']
Executing: ['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '-DOPENCV_INCLUDE_INSTALL_PATH=include', '-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty', '-DIOS_ARCH=armv7', '-DCMAKE_TOOLCHAIN_FILE=/Volumes/t/lib/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake', '-DCPU_BASELINE=DETECT', '/Volumes/t/lib/opencv', '-DCMAKE_C_FLAGS=-fembed-bitcode', '-DCMAKE_CXX_FLAGS=-fembed-bitcode'] in /Volumes/t/lib/opencv/platforms/ios/ios/build/build-armv7-iphoneos
Executing: cmake -GXcode -DAPPLE_FRAMEWORK=ON -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_INCLUDE_INSTALL_PATH=include -DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty -DIOS_ARCH=armv7 -DCMAKE_TOOLCHAIN_FILE=/Volumes/t/lib/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCPU_BASELINE=DETECT /Volumes/t/lib/opencv -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode
============================================================
ERROR: [Errno 2] No such file or directory
============================================================
Traceback (most recent call last):
File "./build_framework.py", line 117, in build
self._build(outdir)
File "./build_framework.py", line 109, in _build
self.buildOne(t[0], t[1], mainBD, cmake_flags)
File "./build_framework.py", line 198, in buildOne
execute(cmakecmd, cwd = builddir)
File "./build_framework.py", line 39, in execute
retcode = check_call(cmd, cwd = cwd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 535, in check_call
retcode = call(*popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
我不确定是否从该错误中找到了哪个文件,有人对使用任一版本的python进行修复有想法吗?
编辑:
看着TypeError: can't use a string pattern on a bytes-like object in re.findall(),我发现如果在第45行的上方添加.decode('utf-8')
,它可以解决“类似字节的对象上的字符串模式”错误,但随后出现相同的subprocess.py错误:{ {1}}