关于pip install [packages]报错的完美解决方法
错误信息
pip install [packages] 报如下错误
ERROR: Command errored out with exit status 1:
command: 'c:\users\lun\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lun\\AppData\\Local\\Temp\\pip-install-kdks3g5l\\netifaces_e72519e4d21d48dbbdf71a7157936488\\setup.py'"'"'; __file__='"'"'C:\\Users\\lun\\AppData\\Local\\Temp\\pip-install-kdks3g5l\\netifaces_e72519e4d21d48dbbdf71a7157936488\\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\lun\AppData\Local\Temp\pip-record-8m0w8raq\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\lun\appdata\local\programs\python\python39\Include\netifaces'
cwd: C:\Users\lun\AppData\Local\Temp\pip-install-kdks3g5l\netifaces_e72519e4d21d48dbbdf71a7157936488\
Complete output (5 lines):
running install
running build
running build_ext
building 'netifaces' extension
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: 'c:\users\lun\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lun\\AppData\\Local\\Temp\\pip-install-kdks3g5l\\netifaces_e72519e4d21d48dbbdf71a7157936488\\setup.py'"'"'; __file__='"'"'C:\\Users\\lun\\AppData\\Local\\Temp\\pip-install-kdks3g5l\\netifaces_e72519e4d21d48dbbdf71a7157936488\\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\lun\AppData\Local\Temp\pip-record-8m0w8raq\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\lun\appdata\local\programs\python\python39\Include\netifaces' Check the logs for full command output.
从错误信息中发现缺少C++构建工具
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools"
- 方案1,下载构建好的.whl文件直接安装
- 方案2,安装C++构建工具,本地构建
方案2
$ pip install wheel setuptools pip --upgrade
打开error中提示的https://visualstudio.microsoft.com/visual-cpp-build-tools/,下载vs_BuildTools.exe开始安装
选择这三个就可以。
测试
- 安装wordcloud库测试
成功build.
|