- Python : 3.8.13
- OS : Windows 21H1
- Conda : 4.12.0
代码及报错
(pyqtenv) C:\Users\admin>pip install pocketsphinx
Collecting pocketsphinx
Downloading pocketsphinx-0.1.15.tar.gz (29.1 MB)
|████████████████████████████████| 29.1 MB 17 kB/s
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-tdg061gj\\pocketsphinx_b9ced2803c224420862a28c601e97969\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-tdg061gj\\pocketsphinx_b9ced2803c224420862a28c601e97969\\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-rgtwmm3c'
cwd: C:\Users\admin\AppData\Local\Temp\pip-install-tdg061gj\pocketsphinx_b9ced2803c224420862a28c601e97969\
Complete output (6 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
error: command 'swig.exe' failed: None
----------------------------------------
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-tdg061gj\\pocketsphinx_b9ced2803c224420862a28c601e97969\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-tdg061gj\\pocketsphinx_b9ced2803c224420862a28c601e97969\\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-7wgqqfs7\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-tdg061gj\pocketsphinx_b9ced2803c224420862a28c601e97969\
Complete output (8 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
error: command 'swig.exe' failed: None
----------------------------------------
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-tdg061gj\\pocketsphinx_b9ced2803c224420862a28c601e97969\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-tdg061gj\\pocketsphinx_b9ced2803c224420862a28c601e97969\\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-7wgqqfs7\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Develop\Anaconda3\envs\pyqtenv\Include\pocketsphinx' Check the logs for full command output.
conda环境下的解决方法
- 报错的核心内容
error: command 'swig.exe' failed: None
- 使用pip安装swig的话会报错!
- 如果没有conda的话,可以直接找swig.exe程序并添加到环境变量中。
- 访问swig的官网失败
- 使用conda安装swig,成功!
conda install swig
C:\Users\admin>swig -version
SWIG Version 4.0.2
Compiled with i686-w64-mingw32-g++ [i686-w64-mingw32]
Configured options: +pcre
Please see http://www.swig.org for reporting bugs and further information
学习资料
学习推荐
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。