python安裝某系庫時遇到錯誤提示,記錄1

作者20254周前 (08-02)python55

遇到的錯誤如下:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. 
This behaviour is the source of the following dependency conflicts.
wordcloud 1.9.4 requires matplotlib, which is not installed.

這條訊息其實不是「安裝失敗」,而是 pip 在提醒你

「wordcloud 1.9.4 需要 matplotlib,但目前環境裡沒有,所以將來執行 wordcloud 時可能會出錯。」

只要補裝 matplotlib 即可

方法 1:同時安裝(最簡單)

bash
复制
pip install wordcloud matplotlib
bash
复制
pip install -U wordcloud matplotlib

方法 2:先裝 matplotlib,再重裝 wordcloud

bash
复制
pip install matplotlib
pip install --force-reinstall wordcloud

額外提示

  • 如果你使用的是虛擬環境(venv/conda),請先 激活環境 再執行以上指令。
  • 若速度太慢,可加上國內鏡像,例如:
    bash
    复制
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple wordcloud matplotlib
  • 若同時出現「Microsoft Visual C++ 14.0 is required」之類的錯誤,代表需要 C++ 編譯環境;Windows 可安裝 Build Tools for Visual Studio,或直接下載已編譯好的 wheel 檔案(例如從 https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud)。
完成後再執行:
bash
复制
python -c "import wordcloud, matplotlib; print('OK')"
沒有報錯就代表已經搞定!


相关文章