关于安装wordcloud时,出现error解决方案 2022-01-10 Python 暂无评论 2730 次阅读 ``` Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/ Collecting wordcloud Using cached https://pypi.tuna.tsinghua.edu.cn/packages/be/33/5bdd39587f0e8ede3fe12d9d16d6f1fb5e7a43f29621604a949ee362d013/wordcloud-1.8.1.tar.gz (220 kB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Requirement already satisfied: numpy>=1.6.1 in d:\pywork\qmshylda\venv\lib\site-packages (from wordcloud) (1.22.0) Requirement already satisfied: pillow in d:\pywork\qmshylda\venv\lib\site-packages (from wordcloud) (9.0.0) Requirement already satisfied: matplotlib in d:\pywork\qmshylda\venv\lib\site-packages (from wordcloud) (3.5.1) Requirement already satisfied: fonttools>=4.22.0 in d:\pywork\qmshylda\venv\lib\site-packages (from matplotlib->wordcloud) (4.28.5) Requirement already satisfied: cycler>=0.10 in d:\pywork\qmshylda\venv\lib\site-packages (from matplotlib->wordcloud) (0.11.0) Requirement already satisfied: packaging>=20.0 in d:\pywork\qmshylda\venv\lib\site-packages (from matplotlib->wordcloud) (21.3) Requirement already satisfied: python-dateutil>=2.7 in d:\pywork\qmshylda\venv\lib\site-packages (from matplotlib->wordcloud) (2.8.2) Requirement already satisfied: kiwisolver>=1.0.1 in d:\pywork\qmshylda\venv\lib\site-packages (from matplotlib->wordcloud) (1.3.2) Requirement already satisfied: pyparsing>=2.2.1 in d:\pywork\qmshylda\venv\lib\site-packages (from matplotlib->wordcloud) (3.0.6) Requirement already satisfied: six>=1.5 in d:\pywork\qmshylda\venv\lib\site-packages (from python-dateutil>=2.7->matplotlib->wordcloud) (1.16.0) Building wheels for collected packages: wordcloud Building wheel for wordcloud (setup.py): started Building wheel for wordcloud (setup.py): finished with status 'error' Running setup.py clean for wordcloud Failed to build wordcloud Installing collected packages: wordcloud Running setup.py install for wordcloud: started Running setup.py install for wordcloud: finished with status 'error' ERROR: Command errored out with exit status 1: command: 'D:\pywork\qmshyLDA\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\adminz\\AppData\\Local\\Temp\\pip-install-zkfbj0hd\\wordcloud_974813bbb7ea43e4b96816a008970db4\\setup.py'"'"'; __file__='"'"'C:\\Users\\adminz\\AppData\\Local\\Temp\\pip-install-zkfbj0hd\\wordcloud_974813bbb7ea43e4b96816a008970db4\\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\adminz\AppData\Local\Temp\pip-wheel-728zaws_' cwd: C:\Users\adminz\AppData\Local\Temp\pip-install-zkfbj0hd\wordcloud_974813bbb7ea43e4b96816a008970db4\ Complete output (22 lines): running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.10 creating build\lib.win-amd64-3.10\wordcloud copying wordcloud\color_from_image.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\tokenization.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\wordcloud.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\wordcloud_cli.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\_version.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\__init__.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\__main__.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\stopwords -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\DroidSansMono.ttf -> build\lib.win-amd64-3.10\wordcloud warning: cmd_build_py: byte-compiling is disabled, skipping. UPDATING build\lib.win-amd64-3.10\wordcloud/_version.py set build\lib.win-amd64-3.10\wordcloud/_version.py to '1.8.1' running build_ext building 'wordcloud.query_integral_image' 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: Failed building wheel for wordcloud ERROR: Command errored out with exit status 1: command: 'D:\pywork\qmshyLDA\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\adminz\\AppData\\Local\\Temp\\pip-install-zkfbj0hd\\wordcloud_974813bbb7ea43e4b96816a008970db4\\setup.py'"'"'; __file__='"'"'C:\\Users\\adminz\\AppData\\Local\\Temp\\pip-install-zkfbj0hd\\wordcloud_974813bbb7ea43e4b96816a008970db4\\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\adminz\AppData\Local\Temp\pip-record-ag03bpzx\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\pywork\qmshyLDA\venv\include\site\python3.10\wordcloud' cwd: C:\Users\adminz\AppData\Local\Temp\pip-install-zkfbj0hd\wordcloud_974813bbb7ea43e4b96816a008970db4\ Complete output (22 lines): running install running build running build_py creating build creating build\lib.win-amd64-3.10 creating build\lib.win-amd64-3.10\wordcloud copying wordcloud\color_from_image.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\tokenization.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\wordcloud.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\wordcloud_cli.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\_version.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\__init__.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\__main__.py -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\stopwords -> build\lib.win-amd64-3.10\wordcloud copying wordcloud\DroidSansMono.ttf -> build\lib.win-amd64-3.10\wordcloud warning: cmd_build_py: byte-compiling is disabled, skipping. UPDATING build\lib.win-amd64-3.10\wordcloud/_version.py set build\lib.win-amd64-3.10\wordcloud/_version.py to '1.8.1' running build_ext building 'wordcloud.query_integral_image' 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: 'D:\pywork\qmshyLDA\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\adminz\\AppData\\Local\\Temp\\pip-install-zkfbj0hd\\wordcloud_974813bbb7ea43e4b96816a008970db4\\setup.py'"'"'; __file__='"'"'C:\\Users\\adminz\\AppData\\Local\\Temp\\pip-install-zkfbj0hd\\wordcloud_974813bbb7ea43e4b96816a008970db4\\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\adminz\AppData\Local\Temp\pip-record-ag03bpzx\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\pywork\qmshyLDA\venv\include\site\python3.10\wordcloud' Check the logs for full command output. ``` 我们在安装一些Python包时,可能会遇到不能安装的问题,提示为缺C++相应的扩展包。提示为`“Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools”`。 原因是使用pip install 安装的过程中需要c++ 编译,而且有些对编译器依赖有比较高。 经查找,以以下三个方法解决。 一、直接下载对应版本的.whl文件,然后运行pip install xxx.whl进行安装 whl 包的下载地址 ``` https://www.lfd.uci.edu/~gohlke/pythonlibs/ https://pypi.org/project/ ``` 二、按照提示去官网下载Visual Studio https://visualstudio.microsoft.com/zh-hans/downloads/ 注意要安装visual studio的C++开发环境。 三、使用Microsoft Visual C++ Build Tools 可以选择visual studio2019中的单个组件,C++ ATL v141生成工具(x86& x64),也可以安装其他版本的生成工具。如果还不行(实际上我安装了多个版本的,也没有成功),可以选择使用增加C++的桌面开发,但是这样安装量就比较大,相当于安装了Visual Studio。 标签: wordcloud 本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。