windows下安装python库wordCloud报错
换电脑安装wordcloud半天安装失败,记录一下遇到的坑,也给大家节省点时间。
方法1:
错误呢就是下面这个,说没c++编译器,要不就去他给的地址上安装一下,我安装了一下好像没什么用,也没太敢勾选,勾一个,600M,不弄这个了,不太懂C++,换另一个方法~
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching 'wordcloud\TODO'
adding license file 'LICENSE'
writing manifest file 'wordcloud.egg-info\SOURCES.txt'
copying wordcloud\DroidSansMono.ttf -> build\lib.win-amd64-cpython-313\wordcloud
copying wordcloud\query_integral_image.c -> build\lib.win-amd64-cpython-313\wordcloud
copying wordcloud\query_integral_image.pyx -> build\lib.win-amd64-cpython-313\wordcloud
copying wordcloud\stopwords -> build\lib.win-amd64-cpython-313\wordcloud
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/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for wordcloud
Failed to build wordcloud
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (wordcloud)
方法2:
查了资料说可以直接安装whl文件,就是库的离线包,找了半天都是https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
这个网址,打不开了都,然后其他地方都找不到,简直简直了
我想着应该也有类似maven的中心仓库啊,大家怎么都不说,终于找到了
https://pypi.org/
在首页输入要下载的库,然后进来,这里点击Download files,下面有很多版本,找匹配自己电脑的
一般人写到这就没了,然后下载下来,发现不能安装
C:\Users\xxxx>pip install "C:\Users\xxx\Downloads\wordcloud-1.9.3-pp310-pypy310_pp73-win_amd64.whl"
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: wordcloud-1.9.3-pp310-pypy310_pp73-win_amd64.whl is not a supported wheel on this platform.
这里介绍一下怎么找到适合自己电脑安装,这个与版本、系统都有关系
先输入下面的命令 会列出可以安装的
pip debug --verbose
...省略一部分
Compatible tags: 45
cp313-cp313-win_amd64
cp313-abi3-win_amd64
cp313-none-win_amd64
cp312-abi3-win_amd64
cp311-abi3-win_amd64
cp310-abi3-win_amd64
cp39-abi3-win_amd64
cp38-abi3-win_amd64
cp37-abi3-win_amd64
然后可以发现这个tag和文件名中间的一部分是比较相似的,比如wordcloud-1.9.3-cp312-cp312-win_amd64
.whl,有的是cp有的是pp,自己注意一下找到自己电脑支持的包,如果有一模一样,那好了,可以直接下载,安装。
安装的命令是:
pip install "C:\Users\xxxx\Downloads\wordcloud-1.9.3-cp312-cp312-win_amd64.whl"
之后应该就成功了!
然而我的问题是,我的python版本更新一点,是3.13,上面的cp312指的是只能312,麻了,还是不行。
我想着高版本安装低版本能有什么问题啊 。直接改了个名,改成313,然后就OK了
wordcloud-1.9.3-cp313-cp313-win_amd64.whl
C:\Users\xxx>pip install "C:\Users\xxx\Downloads\wordcloud-1.9.3-cp313-cp313-win_amd64.whl"
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing c:\users\xxx\downloads\wordcloud-1.9.3-cp313-cp313-win_amd64.whl
Collecting numpy>=1.6.1 (from wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a9/96/9f61f8f95b6e0ea0aa08633b704c75d1882bdcb331bdf8bfd63263b25b00/numpy-2.1.2-cp313-cp313-win_amd64.whl (12.6 MB)
Collecting pillow (from wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fb/01/3755ba287dac715e6afdb333cb1f6d69740a7475220b4637b5ce3d78cec2/pillow-11.0.0-cp313-cp313-win_amd64.whl (2.6 MB)
Collecting matplotlib (from wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b0/6d/3572fe243c74112fef120f0bc86f5edd21f49b60e8322fc7f6a01fe945dd/matplotlib-3.9.2-cp313-cp313-win_amd64.whl (7.8 MB)
Collecting contourpy>=1.0.1 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/cc/4a/fb3c83c1baba64ba90443626c228ca14f19a87c51975d3b1de308dd2cf08/contourpy-1.3.0-cp313-cp313-win_amd64.whl (218 kB)
Collecting cycler>=0.10 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e7/05/c19819d5e3d95294a6f5947fb9b9629efb316b96de511b418c53d245aae6/cycler-0.12.1-py3-none-any.whl (8.3 kB)
Collecting fonttools>=4.22.0 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/63/da/f7a1d837de419e3d4cccbd0dbf53c7399f610f65ceb9bcbf2480f3ae7950/fonttools-4.54.1-cp313-cp313-win_amd64.whl (2.2 MB)
Collecting kiwisolver>=1.3.1 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0b/db/32e897e43a330eee8e4770bfd2737a9584b23e33587a0812b8e20aac38f7/kiwisolver-1.4.7-cp313-cp313-win_amd64.whl (55 kB)
Collecting packaging>=20.0 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl (53 kB)
Collecting pyparsing>=2.3.1 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/be/ec/2eb3cd785efd67806c46c13a17339708ddc346cbb684eade7a6e6f79536a/pyparsing-3.2.0-py3-none-any.whl (106 kB)
Collecting python-dateutil>=2.7 (from matplotlib->wordcloud==1.9.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Requirement already satisfied: six>=1.5 in c:\users\xxx\appdata\local\programs\python\python313\lib\site-packages (from python-dateutil>=2.7->matplotlib->wordcloud==1.9.3) (1.16.0)
Installing collected packages: python-dateutil, pyparsing, pillow, packaging, numpy, kiwisolver, fonttools, cycler, contourpy, matplotlib, wordcloud
Successfully installed contourpy-1.3.0 cycler-0.12.1 fonttools-4.54.1 kiwisolver-1.4.7 matplotlib-3.9.2 numpy-2.1.2 packaging-24.1 pillow-11.0.0 pyparsing-3.2.0 python-dateutil-2.9.0.post0 wordcloud-1.9.3
按划线的方式是安装好了,但是其实依赖库里编译的包和系统是不匹配的,所以没办法了~ 只能再退一步
卸载当前3.13版本,重新安装3.12
不可能,绝对不可能。
使用多环境管理工具miniConda创建一个版本为3.12的环境
这种更优雅一点 ,参考我另一篇文章:使用miniConda管理不同python环境