【问题标题】:CVXOPT Module Python - DLL load failed: The specified module cannot be foundCVXOPT 模块 Python - DLL 加载失败:找不到指定的模块
【发布时间】:2018-05-01 10:47:44
【问题描述】:

我无法运行此代码。当我运行它时,它给了我一个错误,据我了解,这意味着它无法导入 cvxopt.base 模块。 如果有人遇到过这个错误或者知道这个问题的解决方法,请联系我们。

我在下面分享 Python 接口的代码和跟踪:

代码:

#!/usr/bin/env python

import numpy as np

from numpy import linalg
from cvxopt import solvers

def Twin_plane_1(R,S,C1,Epsi1,regulz1):
    StS = np.dot(S.T,S)
    # for regularization we add identity matrix with wt. before inversion
    StS = StS + regulz1*(np.identity(StS.shape[0]))
    StSRt = linalg.solve(StS,R.T)
    RtStSRt = np.dot(R,StSRt)
    RtStSRt = (RtStSRt+(RtStSRt.T))/2
    m2 = R.shape[0]
    e2 = -np.ones((m2,1))
    solvers.options['show_progress'] = False
    vlb = np.zeros((m2,1))
    vub = C1*(np.ones((m2,1)))
    # x<=vub
    # x>=vlb -> -x<=-vlb
    # cdx<=vcd
    cd = np.vstack((np.identity(m2),-np.identity(m2)))
    vcd = np.vstack((vub,-vlb))
    alpha = solvers.qp(matrix(RtStSRt,tc='d'),matrix(e2,tc='d'),matrix(cd,tc='d'),matrix(vcd,tc='d'))#,matrix(0.0,(1,m1)),matrix(0.0))#,None,matrix(x0))
    alphasol = np.array(alpha['x'])
    z = -np.dot(StSRt,alphasol)
    w1 = z[:len(z)-1]
    b1 = z[len(z)-1]
    return [w1,b1]

痕迹:

Traceback(最近一次调用最后一次):文件 "C:\Users\sau\Downloads\Twin-SVM-master\Twin-SVM-master\TwinPlane1.py", 第 6 行,在 从 cvxopt 导入求解器文件“C:\Python35\lib\site-packages\cvxopt__init__.py”,第 50 行,在 import cvxopt.base ImportError: DLL load failed: 找不到指定的模块。

【问题讨论】:

  • 您的问题是什么?请在您的问题中添加更多详细信息。你可以看到help
  • 这在很大程度上没有意义。没有问题,没有代码,也没有上下文。唯一的线索是相当明显的“找不到模块”语句。大概该模块不在您的代码认为应该在的位置。我不知道python(这只是出现在审查队列中),但我想您必须将模块文件放在特定位置,以便应用程序使用它们。检查您是否在相关环境中这样做了。
  • @ADyson 我已经添加了代码老兄。
  • 好的,你缺少的模块呢?你检查过它在机器上的存在吗?

标签: python python-3.x python-3.5 cvxopt


【解决方案1】:

我遇到了同样的问题...试试这个:

import os
os.environ['PATH'] += r';C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\Library\\mingw- 
w64\\bin'

【讨论】:

  • 请详细解释并说明问题出在哪里以及为什么这种方法会起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-13
  • 2020-02-15
  • 2016-08-08
  • 1970-01-01
  • 2016-11-07
  • 2020-04-18
相关资源
最近更新 更多