Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.

这篇具有很好参考价值的文章主要介绍了Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题描述

找到核心错误error:

1. 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/
  
2.  ERROR: Failed building wheel for wordcloud

翻译:
错误:需要 Microsoft Visual C++ 14.0 或更高版本。使用“Microsoft C++ 构建工具”获取它:https://visualstudio.microsoft.com/visual-cpp-build-tools/
错误:wordcloud 构建轮子失败
分析:1.缺少Microsoft C++组件,需要安装
首先这是一个办法,但是下载Visual太大(100M)
2.建议下载wheel文件

Building wheels for collected packages: wordcloud
  Building wheel for wordcloud (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\Users\20735\anaconda3\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\20735\\AppData\\Local\\Temp\\pip-install-ei543uiq\\wordcloud_976575344b2540e495e42e0a0576368d\\setup.py'"'"'; __file__='"'"'C:\\Users\\20735\\AppData\\Local\\Temp\\pip-install-ei543uiq\\wordcloud_976575344b2540e495e42e0a0576368d\\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\20735\AppData\Local\Temp\pip-wheel-zfgap6p_'
       cwd: C:\Users\20735\AppData\Local\Temp\pip-install-ei543uiq\wordcloud_976575344b2540e495e42e0a0576368d\
  Complete output (20 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\color_from_image.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\tokenization.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\wordcloud.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\wordcloud_cli.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\_version.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\__init__.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\__main__.py -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\stopwords -> build\lib.win-amd64-3.9\wordcloud
  copying wordcloud\DroidSansMono.ttf -> build\lib.win-amd64-3.9\wordcloud
  UPDATING build\lib.win-amd64-3.9\wordcloud/_version.py
  set build\lib.win-amd64-3.9\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

问题解决

这里我们采用的是下载whl文件的方法(文件比较小)
1.咱们先查看python版本,如果你是anaconda也可以的
命令:python --version
Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.
2.打开网址,下载对应的whl文件,我这里是64位3.9的版本
https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud

Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.
3.安装whl文件
将下载好的whl放入Libray文件架(养成习惯,方便管理)
Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.
导航刀whl所在的目录
执行命令:pip install wordcloud-1.8.1-cp39-cp39-win_amd64.whl
提示:这里的命令手动输的话容易出错,可以重命名复制whl的名字就行,反正我是这么干的哈哈哈

Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.
4.接着执行:pip install wordcloud
Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.
因为我这里已经安装了所以是already satisfied

下面是打包好的案例,你只需要把图片路径替换成你的就行

import wordcloud #导入词云库
import numpy as np
import matplotlib.pyplot as plt
import PIL
import jieba
import re
with open(r'Q10_20220412.csv',encoding='utf8') as f:
    text1 = f.readlines()
#导入图片
image1 = PIL.Image.open(r'owl.jpeg ')
MASK = np.array(image1)
WC = wordcloud.WordCloud(font_path = 'C:\\Windows\\Fonts\\STFANGSO.TTF',max_words=2000,mask = MASK,height= 400,width=400,background_color='white',repeat=False,mode='RGBA') #设置词云图对象属性
st1 = re.sub('[,。、“”‘ ’]','',str(text1)) #使用正则表达式将符号替换掉。
conten = ' '.join(jieba.lcut(st1)) #此处分词之间要有空格隔开,联想到英文书写方式,每个单词之间都有一个空格。
con = WC.generate(conten)
plt.imshow(con)
plt.axis("off")
plt.savefig('111.png')
plt.show()

Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.文章来源地址https://www.toymoban.com/news/detail-461093.html

到了这里,关于Python 安装wordcloud报错error: Microsoft Visual C++ 14.0 or greater is required.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包