首页 > 解决方案 > 为什么我无法在 spyder (v 3.3.4) 中加载 wordcloud?

问题描述

无论我做什么,我都不能在 Anaconda 中使用 wordcloud - spyder

    import wordcloud
Traceback (most recent call last):

  File "<ipython-input-104-dc1828f2a80e>", line 1, in <module>
    import wordcloud

ModuleNotFoundError: No module named 'wordcloud'

经过一番研究,我意识到我需要通过 shell 程序安装包。所以我使用 pip 命令安装了 wordcloud

C:\Users\1025990\AppData\Local\Programs\Python\Python37-32\Scripts>pip install wordcloud
Collecting wordcloud
  Using cached https://files.pythonhosted.org/packages/d4/95/d260ce89441d1f28192fa5a0a016f547829517b11cabe0079ab91c56f6cd/wordcloud-1.5.0.tar.gz
Requirement already satisfied: numpy>=1.6.1 in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (1.16.4)
Requirement already satisfied: pillow in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (6.0.0)
Building wheels for collected packages: wordcloud
  Building wheel for wordcloud (setup.py) ... done
  Stored in directory: C:\Users\1025990\AppData\Local\pip\Cache\wheels\0a\24\57\899dc50402fef8c355561bcfadfe36879def229e6d97424281
Successfully built wordcloud
Installing collected packages: wordcloud
  WARNING: The script wordcloud_cli.exe is installed in 'c:\users\1025990\appdata\local\programs\python\python37-32\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed wordcloud-1.5.0

我知道警告与安装无关,因为更改环境变量会消除它。我已经做到了(但没有在这里发布)

之后我再次执行了shell命令

C:\Users\1025990\AppData\Local\Programs\Python\Python37-32\Scripts>pip install wordcloud
Requirement already satisfied: wordcloud in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (1.5.0)
Requirement already satisfied: numpy>=1.6.1 in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (1.16.4)
Requirement already satisfied: pillow in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (6.0.0)

我也更新了 shell 中的设置工具

C:\Users\1025990\AppData\Local\Programs\Python\Python37-32\Scripts>pip install -U setuptools
Requirement already up-to-date: setuptools in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (41.0.1)

现在我检查是否可以在 spyder 中使用 wordcloud,所以我再次运行命令

from wordcloud import WordCloud
Traceback (most recent call last):

  File "<ipython-input-105-021e0a03a31f>", line 1, in <module>
    from wordcloud import WordCloud

ModuleNotFoundError: No module named 'wordcloud'

我不明白我错过了什么。请帮忙!

标签: python

解决方案


您是否有可能有多个 python 实例并将其安装到另一个而不是您实际使用的实例上?这是此类问题的常见原因。

通过在您的 python 控制台中获取您的实际版本,import sys print(sys.executable)并为您的模块检查此路径的站点包文件夹。


推荐阅读