Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import cvxopt.base: the specified module could not be found

I'm new to Python, just installed cvxopt module for my Python3.3 system (64 bit). The installation was successful, but when I typed "import cvxopt" in Python command line, it returned an error:

File "C:\Program Files (x86)\Python\lib\site-packages\cvxopt__init__.py", line 33, in import cvxopt.base ImportError: DLL load failed: The specified module could not be found.

Could anyone help me on this problem? Thanks a lot!

like image 718
user2055265 Avatar asked Feb 08 '13 17:02

user2055265


4 Answers

The reason for the dll load problem is most likely a very different one. The most up to date Anaconda version (e.g. Anaconda 5.0.1) has Numpy with MKL support. This is NOT the issue. I verified this by looking at the installed packages using conda list. The issue is the fact that cvxopt requires some dlls, which are in the directory

C:\Anaconda3\envs\foo\Library\mingw-w64\bin  

If you install Anaconda and do NOT register Anaconda python on the system path (which is their suggested setup anyway) and then use the Anaconda prommpt to set up a new environment (note for current verison of cvxopt you need Python 3.5)

conda create -n foo python=3.5
activate foo

conda install cvxopt

and importing cvxopt

(foo) C:\tmp>python
Python 3.5.4 |Anaconda, Inc.| (default, Nov  8 2017, 14:34:30) [MSC v.1900 
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvxopt
>>> 

all should work fine. If you check the Anaconda related path settings you will find

C:\Anaconda3\envs\foo;
C:\Anaconda3\envs\foo\Library\mingw-w64\bin;
C:\Anaconda3\envs\foo\Library\usr\bin;
C:\Anaconda3\envs\foo\Library\bin;
C:\Anaconda3\envs\foo\Scripts;

If you now remove C:\Anaconda3\envs\foo\Library\mingw-w64\bin from the path you are back to the problem

C:\tmp>python
Python 3.5.4 |Anaconda, Inc.| (default, Nov  8 2017, 14:34:30) [MSC v.1900 
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvxopt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\envs\tf14\lib\site-packages\cvxopt\__init__.py", line 32, in <module>
    import cvxopt.base
ImportError: DLL load failed: The specified module could not be found.
>>>

However there is another issue, related to PyCharm: how to actually use Anaconda envs properly with PyCharm? PyCharm cannot handle additional paths as required by an environment. At leat not out of the box, or I did not find a way to properly do it. Any suggestions are welcome.

like image 115
Daniel Avatar answered Oct 25 '22 08:10

Daniel


The package CVXOPT requires numpy+mkl, you can try uninstall the numpy package and reinstall numpy+mkl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy, then importing the CVXOPT, it will work.

like image 23
Baokai Zhang Avatar answered Oct 25 '22 07:10

Baokai Zhang


You need to import numpy first before importing cvxopt.

import numpy
import cvxopt
like image 10
Tsung-Han Yang Avatar answered Oct 25 '22 09:10

Tsung-Han Yang


You need to add YourPythonPath\Library\bin to your PATH environment variable. In my case it is C:\Python36-64\Library\bin

like image 9
Artashes Khachatryan Avatar answered Oct 25 '22 07:10

Artashes Khachatryan