python第三方scipy包報錯問題


最近在外網筆記本電腦上在Python環境下使用k-modes做聚類分析算法,今天遷移到公司內網電腦(無法接入互聯網)遇到如下問題記錄一下。

前提Python環境已安裝且完成配置

Python Version:Python 3.7.4

1 #Python腳本引入第三方包如下
2 import sys
3 import pymysql
4 import numpy as np
5 from kmodes.kmodes import KModes

執行python文件后主要錯誤信息如下:

1 from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks,
2                            get_csr_submatrix)
3 ImportError: DLL load failed: The specified module could not be found.

報錯代碼位置出自KModes包依賴的其它包中的scipy包,具體文件為\Python37\Lib\site-packages\scipy\sparse\csr.py

解決:

最終在google上找了一個歪果仁遇到了同樣類似的問題,stackoverflow地址,下面的一條回復如下:


 

Answers:

I believe I have solved your issue, as I encountered the same problem in a completely different way.

You need to update your windows C++ redistributable compiler.

To understand if this is the solution.

  • Check what versions of microsoft C++ redistributable you have installed
    • if you're using windows 10 type apps and features into the start bar and scroll down to where it says microsoft visual C++ and look at the year. In my case I was using a version from 2010
  • If you aren't running the latest version download microsoft visual studio 2017
  • Select the visual studio community 2017

    • Once prompted to install specific packages, click on the menu item that says "individual components", it is located next to the menu item "Workloads"
    • Scroll down and look for Visual C++ 2017 Redistributable Update
    • Install that restart your machine
    • You'll be able to verify that this worked by running the following code in your console

 

主要問題是Microsoft Visual C++版本較低,需升級較高版。

查看內網電腦(控制面板->程序與功能),該電腦安裝的最高版本為Microsoft Visual C++ 2013 Redistributable。從官網獲取最新支持的 Visual C++ 下載並安裝。

最終安裝Microsoft Visual C++ 2017 Redistributable版本后,重啟電腦,運行代碼上述問題解決!

 

寫在最后:

工作學習中遇到過很多問題,很久前就想着記錄在Blog上面,但始終沒有養成這個良好的習慣,僅僅是記錄在本地文檔上面。第一次寫技術Blog作一記錄,並對自己當作鼓勵!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM