- Python : 3.8.13
- OS : Windows 21H1
- Conda : 4.12.0
代码及报错
(pyqtenv) C:\Users\admin>pip install pocketsphinx
Collecting pocketsphinx
Using cached pocketsphinx-0.1.15.tar.gz (29.1 MB)
Building wheels for collected packages: pocketsphinx
Building wheel for pocketsphinx (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'D:\Develop\Anaconda3\envs\pyqtenv\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-rqontst_\\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-rqontst_\\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\admin\AppData\Local\Temp\pip-wheel-g7iv8a15'
cwd: C:\Users\admin\AppData\Local\Temp\pip-install-rqontst_\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\
Complete output (7 lines):
running bdist_wheel
running build_ext
building 'sphinxbase._sphinxbase' extension
swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c
swig.exe -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/win32 -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c deps/sphinxbase/swig/sphinxbase.i
Deprecated command line option: -modern. This option is now always on.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Failed building wheel for pocketsphinx
Running setup.py clean for pocketsphinx
Failed to build pocketsphinx
Installing collected packages: pocketsphinx
Running setup.py install for pocketsphinx ... error
ERROR: Command errored out with exit status 1:
command: 'D:\Develop\Anaconda3\envs\pyqtenv\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-rqontst_\\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-rqontst_\\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\admin\AppData\Local\Temp\pip-record-2yh0p7o_\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Develop\Anaconda3\envs\pyqtenv\Include\pocketsphinx'
cwd: C:\Users\admin\AppData\Local\Temp\pip-install-rqontst_\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\
Complete output (9 lines):
running install
D:\Develop\Anaconda3\envs\pyqtenv\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build_ext
building 'sphinxbase._sphinxbase' extension
swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c
swig.exe -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/win32 -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c deps/sphinxbase/swig/sphinxbase.i
Deprecated command line option: -modern. This option is now always on.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\Develop\Anaconda3\envs\pyqtenv\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-rqontst_\\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-rqontst_\\pocketsphinx_14747db59f0e43d88aa487517f5d96d8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\admin\AppData\Local\Temp\pip-record-2yh0p7o_\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Develop\Anaconda3\envs\pyqtenv\Include\pocketsphinx' Check the logs for full command output.
(pyqtenv) C:\Users\admin>
解决方法
- 报错的核心内容
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
- 访问报错中给出的提示链接
- 重启后,成功安装 pocketsphinx
C:\Users\admin>conda activate pyqtenv
(pyqtenv) C:\Users\admin>pip install pocketsphinx
Collecting pocketsphinx
Using cached pocketsphinx-0.1.15.tar.gz (29.1 MB)
Building wheels for collected packages: pocketsphinx
Building wheel for pocketsphinx (setup.py) ... done
Created wheel for pocketsphinx: filename=pocketsphinx-0.1.15-cp38-cp38-win_amd64.whl size=29109817 sha256=64f81b8e45fc834dcb9c540fd12d6e413a0dc0e485e42ad8d7cad60078750055
Stored in directory: c:\users\admin\appdata\local\pip\cache\wheels\30\98\7e\529701aa2fd808ce345ae23f1fdd8f4bb0aa42ffac8ba058ff
Successfully built pocketsphinx
Installing collected packages: pocketsphinx
Successfully installed pocketsphinx-0.1.15
(pyqtenv) C:\Users\admin>
学习推荐
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。