qpsolvers / qpsolvers

Quadratic programming solvers in Python with a unified API
GNU Lesser General Public License v3.0
578 stars 86 forks source link

Installation on Windows 10 with Microsoft Visual Studio #48

Closed WCHIHO closed 2 years ago

WCHIHO commented 2 years ago

Hello, I got a fatal error when installing qpsolvers using "pip install qpsolvers" having downloaded and installed Microsoft Visual Studio Community 2018 using Python environment including CMaker, MSBuild etc. This is the error message:

" running build_ext -- Selecting Windows SDK version to target Windows 10.0.19043. CMake Error at CMakeLists.txt:4 (project): Failed to run MSBuild command:

MSBuild.exe

to get the value of VCTargetsPath:

The system cannot find the file specified.

cl : Command line warning D9002 : ignoring unknown option '-std=c++11' qdldl.cpp c\qdldl/include/qdldl.h(5): fatal error C1083: Cannot open include file: 'qdldl_types.h': No such file or directory error: command 'C:\Program Files\Microsoft Visual "

After looking into the error messages, I tried to download SDK version to target Windows 10.0.19043. But, Windows SDK 10.0.19043 is not available for download. Windows SDK 10.0.19041 is already installed.

How can I select SDK to target Windows SDK 10.0.19041 instead?

Where else can I install Windows SDK 10.0.19043?

What is this unknown option about: cl : Command line warning D9002 : ignoring unknown option '-std=c++11'?

Why is this file: 'qdldl_types.h' missing causing a fatal error C1083?

WCHIHO commented 2 years ago

Hello,

After by accident I successfully installed qpsolvers after installing Python 3.10 and ran pip install qpsolvers on VSCode, qosolvers is not a name recognized by the Import qpsolver command or any command that has got to do with qpsolvers.

I now lost qpsolver as an installed package in !PIP list. I don't know why although I did see it in the list,

I tried to install it again using pip install qpsolvers. And I saw the errors:

? RuntimeError: CMake must be installed to build qdldl ERROR: Failed building wheel for qdldl

BUT C:\Users\wchih> pip install CMake Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: CMake in c:\users\wchih\appdata\roaming\python\python37\site-packages (3.21.4).

The cause of this error: File "C:\Users\wchih\AppData\Local\Temp\pip-install-yslphgby\qdldl_38da001613504e8099b3c01e97f722f4\setup.py", line 80, in build_extensions raise RuntimeError("CMake must be installed to build qdldl")

I noted python 3.7 is used in the process:

File "c:\program files\python37-32\lib\distutils\command\build_ext.py", line 339, in run self.build_extensions() File "C:\Users\wchih\AppData\Local\Temp\pip-install-yslphgby\qdldl_38da001613504e8099b3c01e97f722f4\setup.py", line 80, in build_extensions raise RuntimeError("CMake must be installed to build qdldl")

So, I tried to run "conda install -c conda-forge qpsolvers" in my jupyter notebook running on python 3.85 as a default. But, I saw error:

"Found conflicts! Looking for incompatible packages."

I am pleased to say that I have successfully installed numpy, wheel, scipy, cython, quadprog etc except qpsolvers. and qdldl.

It 'd be nice to successfully install qpsolvers by "conda install -c conda-forge qpsolvers" in my jupyter notebook. But, what "Found conflicts! Looking for incompatible packages" is about? A version conflict with what package, python?

conda_qpsolvers.docx qpsolvers_errors.docx

Can you help, please?

conda_qpsolvers.docx qpsolvers_errors.docx

WCHIHO commented 2 years ago

I now found out what packages that caused the version conflict whilst using " install -c conda-forge qpsolvers". They are numpy, scipy, panda etc and the whole list of them. See attached file. conda command qpsolvers errors.docx

I think the issue can be resolved. Solution please.

WCHIHO commented 2 years ago

I found out I may need to use Miniforge or Mambaforge to install qpsolvers as suggested in this post. https://stackoverflow.com/questions/67238595/conda-install-unsatisfiableerror But, I'm using using 32 bit Windows 10 while I can update to 64 bits.

WCHIHO commented 2 years ago

I found out stephane-caron 's comment here: https://github.com/stephane-caron/qpsolvers/issues/22

i noted that before and ran sudo apt-get install python3-dev. But, "sudo" is an invalid syntax. In fact, the whole command is an invalid syntax.

However, the solution seems to be similar in this post: https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory/21530768#21530768

I'm looking into it.

stephane-caron commented 2 years ago

I found out stephane-caron 's comment here: #22

Note that comment if for Linux. Since you are using Windows it is not applicable.

@WCHIHO let's focus first on installing qpsolvers in Visual Studio. In your message here https://github.com/osqp/qdldl/issues/42#issuecomment-967211273 you wrote:

You are right. My existing python package is 3.8.8 whilst I use Jupyter notebook and VS Code to run the programmes. I immediately updated my python package to 3.10. I then used VS Code to run “pip install qpsolvers”. The installation process was much complex and lengthy. It kept going down the scipy version from say 1.56 to 1.40. Eventually the installation was successful. The results can be described below: [...] I also checked the results in Jupyter Notebook using “!pip list”:

Before going to a Jupyter Notebook, let's verify from the start that everything works in Visual Studio itself. From what I understand, your configuration is:

Can you execute the following instructions step by step:

import qpsolvers
print(qpsolvers.available_solvers)

At this point a python.exe window should open containing a list of solvers, for example:

['quadprog']
Press any key to continue . . . 

Report the outcome here if any step in this list does not happen as expected.

WCHIHO commented 2 years ago

Here is the error report after following your instruction: https://onedrive.live.com/edit.aspx?cid=f603dbe4f8c488ec&page=view&resid=F603DBE4F8C488EC!83809&parId=F603DBE4F8C488EC!103&app=Word&wacqt=mru

Copy the link and paste in the address bar of your browser to view.

I made a number of observations:

  1. The project created could find out PYPI, qpsolvers and then ran PIP install qpsolvers.
  2. It was running in python 3.7 32 bit environment.
  3. File "C:\Users\wchih\AppData\Local\Temp\pip-install-32yeytp4\qdldl\setup.py", line 80, in build_extensions

    raise RuntimeError("CMake must be installed to build qdldl")

    RuntimeError: CMake must be installed to build qdldl

BUT, CMake is already installed. 4.WARNING: You are using pip version 20.1.1; however, version 21.3.1 is available.

While not a big deal, version 21.3.1 is already installed.

  1. Foolishly I uninstalled python 3.7 and installed Python 10 to see the difference. I could not find PYPI, but a long list of packages in particular qpsolvers. I ran pip install qpsolvers in terminal. PIP is not recognized as command. It is due to the removal of Python version 3.7. That path no longer exists.
  2. I reinstalled Python 3.7. This times PYPI could not be found including qpsolvers. There were just a few packages such as numpy.
  3. I installed Python 3.85 to see the difference. Again PYPI could not be found and qpsolvers was not in the list compared with Python version 3.10. Same as version 3.7 a few packages appeared.
  4. I am disappointed to realize I can no longer follow your instructions to get into PYPI. look for qpsolvers and run pip install qpsolvers from underneath the search box where qpsolvers is being searched.
  5. I am grateful and appreciate your kind assistance..
  6. Last and least, I updated my Windows 10 to the most update 32 bit version. It took a long time. There seems to be no need to update to 64 bit while my processor is 64 bit capable or Windows 11 (a new pc).
WCHIHO commented 2 years ago

Well, I had a go again and discovered that when I clicked "start", vs studio ran "pip install qpsolvers". I ran the start program after I searched for qpsolvers in the sear box under python environment 3.10 version.

The installation stopped due to missing a comma. See attached file. vs studio qpsolvers error 211121.docx

WCHIHO commented 2 years ago

O.K After I typed in "pip" in the terminal, I got this error:

PS C:\Users\wchih> pip Fatal error in launcher: Unable to create process using '"c:\program files\python37-32\python.exe" "C:\Program Files\Python37-32\Scripts\pip.exe" ': The system cannot find the file specified.

WCHIHO commented 2 years ago

PIP is found in the scripts folder. The PATH to that folder c:\program files\python37-32\python.exe" "C:\Program Files\Python37-32\Scripts is still there. Why can't it find the file specified?

WCHIHO commented 2 years ago

The syntax error is pointing at "install qpsolvers" which is a built-in command within vs studio under python 3.10 environment and is independent of python 3.7. Why a comma is missing in this case when the command is generated automatically by vs studio?

P.S. Monday morning 22/11/2021 Not really automatically generated. I input "pip install qpsolvers" myself in the project in visual studio which runs my codes.

WCHIHO commented 2 years ago

The issue can be boiled down to "pip install qpsolvers" which cannot be executed due to syntax error. I made the following observations:

There is a file named runpy.py (see attached file) within the folder named lib inside the folder Python310-32 which is the python environment of this project, ThursdayTest.py. In line 242, in _get_code_from_file code = compile(f.read(), fname, 'exec') File , it looks for the ThursdayTest.py project file which has a one line code in line 2 namely, "pip install qpsolvers". At this parsing stage the python program encounters an error and stops there.

At the bottom of the message:

"C:\Users\wchih\source\repos\ThursdayTest\ThursdayTest\ThursdayTest.py", line 2 pip install qpsolvers ^^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma? The thread 0x1 has exited with code 0 (0x0). The program 'python.exe' has exited with code 1 (0x1).

It seems to me the syntax error is unrelated to the error below in vs code terminal: PS C:\Users\wchih> pip install qpsolver Fatal error in launcher: Unable to create process using '"c:\program files\python37-32\python.exe" "C:\Program Files\Python37-32\Scripts\pip.exe" install qpsolvers': The system cannot find the file specified.

kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

vs studio qpsolvers error 211121.docx :
runpy.docx

WCHIHO commented 2 years ago

Further investigation points to the syntax error in "pip install qpsolvers" as explained by vs studio's error list: Severity Code Description Project File Line Suppression State Error unexpected token 'install' C:\Users\wchih\source\repos\ThursdayTest\ThursdayTest\ThursdayTest.py 2

What is "Unexpected token"? What error is this?

WCHIHO commented 2 years ago

Unexpected token errors are caused by incompatibilities in your parser options and the code you’re writing.

https://grantnorwood.com/eslint-parsing-error-unexpected-token-visual-studio-code/

WCHIHO commented 2 years ago

I think the reason why vs studio started to run "pip install qpsolvers" when I clicked the "start" button is I typed in "pip installed qpsolvers" in the top left box.

I created a new project and use Python 3.10 environment. When I clicked "start", I got this message: The thread 'MainThread' (0x1) has exited with code 0 (0x0). The program 'python.exe' has exited with code 0 (0x0).

WCHIHO commented 2 years ago

I noted a message which said that I used python 3.10 which is not fully supported by vs studio. I also found this web page which said similar things:

https://github.com/microsoft/PTVS/issues/5822

WCHIHO commented 2 years ago

I ran "pip install qpsolvers" in Anaconda Spyder and got the output as before using the other terminals. But, Spyder ran the program very quickly. qpsolvers_spyder.pdf

WCHIHO commented 2 years ago

I just noted this error message in the output of Spyder which I used to run "pip install qpsolvers":

running install C:\Users\wchih\anaconda3\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

So, the installation file named "install.py" is depreciated. Use build and pip and other standards-based tools. What are these tools? Visual Studio? C++ build tools?

Spider is a good program and runs quickly and produces more details.

See attached file. qpsolvers_spyder.pdf

WCHIHO commented 2 years ago

O.K. I discovered using "python -m pip install qpsolvers" instead of "pip install qpsolvers" it runs.

PS C:\Users\wchih\OneDrive\Desktop\Python> python -m pip install qpsolvers Requirement already satisfied: qpsolvers in c:\users\wchih\appdata\local\programs\python\python310-32\lib\site-packages (1.7.0) Requirement already satisfied: quadprog>=0.1.8 in c:\users\wchih\appdata\local\programs\python\python310-32\lib\site-packages (from qpsolvers) (0.1.10) Requirement already satisfied: numpy in c:\users\wchih\appdata\local\programs\python\python310-32\lib\site-packages (from quadprog>=0.1.8->qpsolvers) (1.21.4)

WCHIHO commented 2 years ago

I'm pleased to report that I found out there is a button which is used to manage python environment. Once a click on it, PyPI package appears and I can search qpsolvers as before and click on "Run command: pip install qpsolvers".

It is this button which solves the issue.

Many thanks!

WCHIHO commented 2 years ago

Please to say that:

Requirement already satisfied: quadprog>=0.1.8 in c:\users\wchih\appdata\local\programs\python\python310-32\lib\site-packages (from qpsolvers) (0.1.10) ----- Successfully installed 'qpsolvers' -----

WCHIHO commented 2 years ago

Result of:

import qpsolvers print(qpsolvers.available_solvers)

Message=No module named 'cvxopt' Source=C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py StackTrace: File "C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py", line 2, in (Current frame) import qpsolvers

failed import qpsolvers.pdf

I had encountered this issue before and mentioned it to you:

ModuleNotFoundError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_7184/3128229837.py in ----> 1 import qpsolvers 2 print(qpsolvers.available_solvers)

ModuleNotFoundError: No module named 'qpsolvers'

WCHIHO commented 2 years ago

A big file of the errors reported during the installation of qpsolvers. At the bottom of the report it is stated that qpsolvers has been successfully installed. But, qpsolvers can't be found by "import qpsolvers" as there is no such module. So, qpsolvers has not be installed.

The installation spent a lot of time trying to build scipy which requires libraries named BLAS/LAPACK.

numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. To build Scipy from sources, BLAS & LAPACK libraries need to be installed. See site.cfg.example in the Scipy source directory and https://docs.scipy.org/doc/scipy/reference/building/index.html for details.

In jupyter notebook scipy is in the !pip list which means it is already installed without going through all these hassle But, why Visual Studio still tries to install scipy?

It is a big pdf file and I can't attach here.

Main points:

----- Installing 'qpsolvers' ----- Requirement already satisfied: qpsolvers in c:\users\wchih\appdata\local \programs\python\python310-32\lib\site-packages (1.7.0)

Requirement already satisfied: quadprog>=0.1.8 in c:\users\wchih\appdata\local \programs\python\python310-32\lib\site-packages (from qpsolvers) (0.1.10) ----- Successfully installed 'qpsolvers' ---- (No, it is not.)

WCHIHO commented 2 years ago

Just to confirm that:

I am using Windows 10 32 bit and Visual Studio Professional 2019.

WCHIHO commented 2 years ago

Using Anaconda Spyder, I ran:

import numpy as np %pylab inline import scipy as sp import scipy.linalg as la

np.config.show()

The output of the above is:

Populating the interactive namespace from numpy and matplotlib blas_mkl_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:/Users/wchih/anaconda3\Library\include'] blas_opt_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:/Users/wchih/anaconda3\Library\include'] lapack_mkl_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:/Users/wchih/anaconda3\Library\include'] lapack_opt_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:/Users/wchih/anaconda3\Library\include']

The above show the libraries mkl_rt, indicating that the system is using Intel’s math kernel library (MKL) - this is a library of mathematical functions (including BLAS and LAPACK) which is optimized for Intel CPUs, and is the default for Anaconda Python.

Conclusion: Scipy has successfully been installed. And the requirement to install Scipy by using Visual Studio Professional 2019 is a bug whilst during the process of "pip install qpsolvers"???

WCHIHO commented 2 years ago

Running import scipy as sp sp.config.show()

I get the same result: lapack_mkl_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\include', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\lib', 'C:/Users/wchih/anaconda3\Library\include'] lapack_opt_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\include', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\lib', 'C:/Users/wchih/anaconda3\Library\include'] blas_mkl_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\include', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\lib', 'C:/Users/wchih/anaconda3\Library\include'] blas_opt_info: libraries = ['mkl_rt'] library_dirs = ['C:/Users/wchih/anaconda3\Library\lib'] define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)] include_dirs = ['C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\include', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\lib', 'C:/Users/wchih/anaconda3\Library\include']

WCHIHO commented 2 years ago

As an alternative, I successfully installed cvxopt and could run this program in Jupyter Notebook and saw two beautiful graphs:

from math import sqrt from cvxopt import matrix from cvxopt.blas import dot from cvxopt.solvers import qp, options

n = 4 S = matrix( [[ 4e-2, 6e-3, -4e-3, 0.0 ], [ 6e-3, 1e-2, 0.0, 0.0 ], [-4e-3, 0.0, 2.5e-3, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ]] ) pbar = matrix([.12, .10, .07, .03])

G = matrix(0.0, (n,n)) G[::n+1] = -1.0 h = matrix(0.0, (n,1)) A = matrix(1.0, (1,n)) b = matrix(1.0)

N = 100 mus = [ 10*(5.0t/N-1.0) for t in range(N) ] options['show_progress'] = False xs = [ qp(muS, -pbar, G, h, A, b)['x'] for mu in mus ] returns = [ dot(pbar,x) for x in xs ] risks = [ sqrt(dot(x, Sx)) for x in xs ]

try: import pylab except ImportError: pass else: pylab.figure(1, facecolor='w') pylab.plot(risks, returns) pylab.xlabel('standard deviation') pylab.ylabel('expected return') pylab.axis([0, 0.2, 0, 0.15]) pylab.title('Risk-return trade-off curve (fig 4.12)') pylab.yticks([0.00, 0.05, 0.10, 0.15])

pylab.figure(2, facecolor='w')
c1 = [ x[0] for x in xs ]
c2 = [ x[0] + x[1] for x in xs ]
c3 = [ x[0] + x[1] + x[2] for x in xs ]
c4 = [ x[0] + x[1] + x[2] + x[3] for x in xs ]
pylab.fill(risks + [.20], c1 + [0.0], facecolor = '#F0F0F0')
pylab.fill(risks[-1::-1] + risks, c2[-1::-1] + c1,
    facecolor = '#D0D0D0')
pylab.fill(risks[-1::-1] + risks, c3[-1::-1] + c2,
    facecolor = '#F0F0F0')
pylab.fill(risks[-1::-1] + risks, c4[-1::-1] + c3,
    facecolor = '#D0D0D0')
pylab.axis([0.0, 0.2, 0.0, 1.0])
pylab.xlabel('standard deviation')
pylab.ylabel('allocation')
pylab.text(.15,.5,'x1')
pylab.text(.10,.7,'x2')
pylab.text(.05,.7,'x3')
pylab.text(.01,.7,'x4')
pylab.title('Optimal allocations (fig 4.12)')
pylab.show()
WCHIHO commented 2 years ago

I copied your example using cvxopt instead of qpsolvers as follows:

from numpy import array, dot from cvxopt.blas import dot from cvxopt.solvers import qp

M = array([[1., 2., 0.], [-8., 3., 2.], [0., 1., 1.]]) P = dot(M.T, M) # this is a positive definite matrix q = dot(array([3., 2., 3.]), M).reshape((3,)) G = array([[1., 2., 1.], [2., 0., 1.], [-1., 2., -1.]]) h = array([3., 2., -2.]).reshape((3,)) A = array([1., 1., 1.]) b = array([1.])

x = qp(P, q, G, h, A, b) print("QP solution: x = {}".format(x))

I got this output: TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_8224/1684931638.py in 4 5 M = array([[1., 2., 0.], [-8., 3., 2.], [0., 1., 1.]]) ----> 6 P = dot(M.T, M) # this is a positive definite matrix 7 q = dot(array([3., 2., 3.]), M).reshape((3,)) 8 G = array([[1., 2., 1.], [2., 0., 1.], [-1., 2., -1.]])

TypeError: x must be a matrix

So, there is no syntax error, but a type error: x must be a matrix.

Are you able to fix this type error?

stephane-caron commented 2 years ago

Thank you for your persistence in trying to get things to work. However, for meaningful assistance we should stick to one point per issue.

The point of this issue is: how to install qpsolvers on Windows 10 using Microsoft Visual Studio. For moving to a different topic, you can do one of the following:

Now, back to your original issue. From the information you reported I noticed:

It was running in python 3.7 32 bit environment.

As we discussed previously in this qdldl issue, the dependency qdldl will not be installed properly with Python 3.7 (it requires at least Python 3.8). We will address this below.

I ran "pip install qpsolvers" in Anaconda Spyder and got the output as before using the other terminals. But, Spyder ran the program very quickly. qpsolvers_spyder.pdf

Hmm, it looks like this one also ran into trouble trying to install qdldl.

Let's try something: it was my mistake to make qdldl a necessary dependency, as it is only required for OSQP and will be installed automatically alongside it. I've just pushed a new version 1.7.2 of qpsolvers that removes the dependency on qdldl (necessary dependencies are now: [numpy, quadprog, scipy]). This should help.

@WCHIHO Would you be so kind as to run again, from the start, the instructions above for Visual Studio? Please use a Python 3.7 environment if you can, this should work now.

WCHIHO commented 2 years ago

Hello, Stephane,

Thanks indeed your very helpful reply.

I carried out your new instructions using python 3.7 in Visual Studio Professional 2019 and can confirm that the result is positive. It ran shorter and quickly.

I also successfully installed qpsolvers in jupyter notebook. It was also very short and quick. Qpsolvers is list as installed in !pip list in jupyter notebook. I performed two test in Jupyter Notebook:

FIRST, import qpsolvers print(qpsolvers.available_solvers)

I got the output as expected quickly: ['cvxopt', 'quadprog']

SECOND,

After I ran your example, I got the output quickly as expected: QP solution: x = [ 0.30769231 -0.69230769 1.38461538]

BUT, I must say that I was disappointed to see an error when I ran in Visual Studio:

import qpsolvers print(qpsolvers.available_solvers)

ERROR: Message=No module named 'qpsolvers' Source=C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py StackTrace: File "C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py", line 2, in (Current frame) import qpsolvers

BUT, I also saw this error message when I ran the above:

Message=No module named 'cvxopt' Source=C:\Users\wchih\source\repos\ThursdayTest\ThursdayTest\ThursdayTest.py StackTrace: File "C:\Users\wchih\source\repos\ThursdayTest\ThursdayTest\ThursdayTest.py", line 2, in (Current frame) import qpsolvers

CONCLUSION: It seems to me the program got mixed up "qpsolvers" with "cvxopt". BUT, "cvxopt" is one of the two solvers in qpsolvers. I wondered if the error due to missing "cvxopt" in qpsolvers. I then installed successfully "cvxopt" Another BUT, Message=No module named 'qpsolvers' still showed up.

FURTHER, I ran your example and failed and saw the error message again and three warning messages:

Message=No module named 'qpsolvers' Source=C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py StackTrace: File "C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py", line 2, in (Current frame) import qpsolvers ark Accent 4"/> <w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 4"/> <w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 4"/> <w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 5"/>

<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 5"/> <w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 5"/> <w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 6"/>

<w:LsdException Locked="false" Priority="51" Name="Grid Table 6Severity Code Description Project File Line Suppression State Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 2
Warning unresolved import 'numpy' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 4
Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 5
Colorful Accent 6"/> <w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 6"/>

<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 1"/>

<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 1"/> <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 1"/> <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 2"/>

<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 2"/> <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 2"/> <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 3"/>

<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 3"/> <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 3"/> <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 4"/>

<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 4"/> <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 4"/> <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 5"/>

<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 5"/> <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 5"/> <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 6"/>

<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 6"/> <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 6"/> </w:LatentStyles> <![endif]-->

Severity | Code | Description | Project | File | Line | Suppression State -- | -- | -- | -- | -- | -- | -- Warning |   | unresolved import 'qpsolvers' | SundayTest | C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py | 2 |   Warning |   | unresolved import 'numpy' | SundayTest | C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py | 4 |   Warning |   | unresolved import 'qpsolvers' | SundayTest | C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py | 5 |  

1>

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

Severity | Code | Description | Project | File | Line | Suppression State -- | -- | -- | -- | -- | -- | -- Warning |   | unresolved import 'qpsolvers' | SundayTest | C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py | 2 |   Warning |   | unresolved import 'numpy' | SundayTest | C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py | 4 |   Warning |   | unresolved import 'qpsolvers' | SundayTest | C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py | 5 |  

Severity Code Description Project File Line Suppression State Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 2
Warning unresolved import 'numpy' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 4
Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 5

Severity Code Description Project File Line Suppression State Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 2
Warning unresolved import 'numpy' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 4
Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 5

Severity Code Description Project File Line Suppression State Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 2
Warning unresolved import 'numpy' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 4
Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 5
Severity Code Description Project File Line Suppression State Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 2
Warning unresolved import 'numpy' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 4
Warning unresolved import 'qpsolvers' SundayTest C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py 5

WCHIHO commented 2 years ago

Hello, Stephane,

Thanks indeed your very helpful reply.

I carried out your new instructions using python 3.7 in Visual Studio Professional 2019 and can confirm that the result is positive. It ran shorter and quickly.

I also successfully installed qpsolvers in jupyter notebook. It was also very short and quick. Qpsolvers is listed as installed in !pip list in jupyter notebook. I performed two tests in Jupyter Notebook:

FIRST, import qpsolvers print(qpsolvers.available_solvers)

I got the output as expected quickly: ['cvxopt', 'quadprog']

SECOND,

After I ran your example, I got the output quickly as expected: QP solution: x = [ 0.30769231 -0.69230769 1.38461538]

BUT, I must say that I was disappointed to see an error when I ran in Visual Studio:

import qpsolvers print(qpsolvers.available_solvers)

ERROR: Message=No module named 'qpsolvers' Source=C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py StackTrace: File "C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py", line 2, in (Current frame) import qpsolvers

BUT, I also saw this error message when I ran the above:

Message=No module named 'cvxopt' Source=C:\Users\wchih\source\repos\ThursdayTest\ThursdayTest\ThursdayTest.py StackTrace: File "C:\Users\wchih\source\repos\ThursdayTest\ThursdayTest\ThursdayTest.py", line 2, in (Current frame) import qpsolvers

CONCLUSION: It seems to me the program got mixed up "qpsolvers" with "cvxopt". BUT, "cvxopt" is one of the two solvers in qpsolvers. I wondered if the error due to missing "cvxopt" in qpsolvers. I then installed successfully "cvxopt" Another BUT, Message=No module named 'qpsolvers' still showed up.

FURTHER, I ran your example and failed and saw the error message again and three warning messages:

Message=No module named 'qpsolvers' Source=C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py StackTrace: File "C:\Users\wchih\source\repos\SundayTest\SundayTest\SundayTest.py", line 2, in (Current frame) import qpsolvers

WARNINGS:

1> unresolved import 'qpsolvers'

2> unresolved import 'qpsolvers'

3> unresolved import 'numpy'

Kindly address the issue and advise me accordingly.

Kindest regards,

William Chan

From: Stéphane Caron @.> Sent: 24 November 2021 18:30 To: stephane-caron/qpsolvers @.> Cc: William Chi Ho Chan @.>; Mention @.> Subject: Re: [stephane-caron/qpsolvers] Installation on Windows 10 with Microsoft Visual Studio (Issue #48)

Thank you for your persistence in trying to get things to work. However, for meaningful assistance we should stick to one point per issue.

The point of this issue is: how to install qpsolvers on Windows 10 using Microsoft Visual Studio. For moving to a different topic, you can do one of the following:

Now, back to your original issue. From the information you reported I noticed:

It was running in python 3.7 32 bit environment.

As we discussed previously in this qdldl issue https://github.com/osqp/qdldl/issues/42 , the dependency qdldl will not be installed properly with Python 3.7 (it requires at least Python 3.8). We will address this below.

I ran "pip install qpsolvers" in Anaconda Spyder and got the output as before using the other terminals. But, Spyder ran the program very quickly. qpsolvers_spyder.pdf

Hmm, looks like this one also ran into trouble trying to install qdldl.

It was my mistake to make qdldl a necessary dependency, as it is only required for OSQP and will be installed automatically alongside it. I've just pushed a new version 1.7.2 of qpsolvers that removes the dependency on qdldl (necessary dependencies are now: [numpy, quadprog, scipy]). This should help.

@WCHIHO https://github.com/WCHIHO Would you be so kind as to run again, from the start, the instructions above for Visual Studio https://github.com/stephane-caron/qpsolvers/issues/48#issuecomment-972634841 ? Please use a Python 3.7 environment if you can, this should work now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stephane-caron/qpsolvers/issues/48#issuecomment-978126192 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSYP3NC2KZIAGOVULRQASLUNUVI7ANCNFSM5IE7YZ6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/ACSYP3JFQLESDP6HQYIYIULUNUVI7A5CNFSM5IE7YZ6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHJGQK4A.gif