mac 安装ctcdecode

网友投稿 1145 2022-08-22

mac 安装ctcdecode

mac 安装ctcdecode

今天在mac上安装ctcdecode的时候碰到了很多问题,这里分享一下我的安装过程:

git clone --recursive ctcdecodepip install wgetpip install .

可能会报错:

(base) ➜ ctcdecode git:(master) pip install .Looking in indexes: /Users/admin/Documents/pythonFiles/speech_recognition/ctcdecode ERROR: Complete output from command python setup.py egg_info: ERROR: Traceback (most recent call last): File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 1317, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/Users/admin/anaconda3/lib/python3.7/line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/Users/admin/anaconda3/lib/python3.7/line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Users/admin/anaconda3/lib/python3.7/line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Users/admin/anaconda3/lib/python3.7/line 1016, in _send_output self.send(msg) File "/Users/admin/anaconda3/lib/python3.7/line 956, in send self.connect() File "/Users/admin/anaconda3/lib/python3.7/line 1384, in connect super().connect() File "/Users/admin/anaconda3/lib/python3.7/line 928, in connect (self.host,self.port), self.timeout, self.source_address) File "/Users/admin/anaconda3/lib/python3.7/socket.py", line 727, in create_connection raise err File "/Users/admin/anaconda3/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) TimeoutError: [Errno 60] Operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "/private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-req-build-8prjlgea/setup.py", line 43, in import build File "/private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-req-build-8prjlgea/build.py", line 27, in 'third_party/openfst-1.6.7.tar.gz') File "/private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-req-build-8prjlgea/build.py", line 16, in download_extract wget.download(url, out=dl_path) File "/Users/admin/anaconda3/lib/python3.7/site-packages/wget.py", line 526, in download (tmpfile, headers) = ulib.urlretrieve(binurl, tmpfile, callback) File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 247, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 1360, in context=self._context, check_hostname=self._check_hostname) File "/Users/admin/anaconda3/lib/python3.7/urllib/request.py", line 1319, in do_open raise URLError(err) urllib.error.URLError: ----------------------------------------ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-req-build-8prjlgea/

这需要单独-:

# Download/Extract openfst, boostdownload_extract(' 'third_party/openfst-1.6.7.tar.gz')download_extract(' 'third_party/boost_1_67_0.tar.gz')

需要自行-这两个文件,并把它们解压到​​third_party​​目录下,然后注释掉这两行。安装的时候你可能会遇见下面的问题:

(base) ➜ ctcdecode git:(master) ✗ pip install .Looking in indexes: /Users/admin/Documents/pythonFiles/speech_recognition/ctcdecodeBuilding wheels for collected packages: ctcdecode Building wheel for ctcdecode (setup.py) ... error ERROR: Complete output from command /Users/admin/anaconda3/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-req-build-5guc0sqe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-wheel-h2y7svan --python-tag cp37: ERROR: /Users/admin/anaconda3/lib/python3.7/distutils/extension.py:131: UserWarning: Unknown Extension options: 'package', 'with_cuda' warnings.warn(msg) running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.7-x86_64-3.7 creating build/lib.macosx-10.7-x86_64-3.7/ctcdecode copying ctcdecode/__init__.py -> build/lib.macosx-10.7-x86_64-3.7/ctcdecode running build_ext /Users/admin/anaconda3/lib/python3.7/site-packages/torch/utils/cpp_extension.py:191: UserWarning: !! WARNING !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your compiler (g++) is not compatible with the compiler Pytorch was built with for this platform, which is clang++ on darwin. Please use clang++ to to compile your extension. Alternatively, you may compile PyTorch from source using g++, and then you can also use g++ to compile your extension. See for help with compiling PyTorch from source. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! WARNING !! platform=sys.platform)) building 'ctcdecode._ext.ctc_decode' extension creating build/temp.macosx-10.7-x86_64-3.7 creating build/temp.macosx-10.7-x86_64-3.7/ctcdecode....

输入下面的命令:

CFLAGS=-stdlib=libc++ pip install .

安装成功:

(base) ➜ ctcdecode git:(master) ✗ CFLAGS=-stdlib=libc++ pip install . Looking in indexes: /Users/admin/Documents/pythonFiles/speech_recognition/ctcdecodeBuilding wheels for collected packages: ctcdecode Building wheel for ctcdecode (setup.py) ... done Stored in directory: /private/var/folders/5h/mjbc_z1n7m91q21xw9_m217m0000gn/T/pip-ephem-wheel-cache-ijax0yt1/wheels/12/b1/84/2050969d4c4b54255b7ff02447919e11bcd313f8e54ed47283Successfully built ctcdecodeInstalling collected packages: ctcdecodeSuccessfully installed ctcdecode-0.4

参考文献

[1]. macos: pip install failed. ​​https://github.com/parlance/ctcdecode/issues/101​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:迁移Swift3.0爬坑与Swift交互OC之变化(swift 面向协议)
下一篇:史上最全解析Android消息推送解决方案(android消息推送实现)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~