Repository: Qiskit/qiskit

Issue:
NLopt install instructions are outdated
### What should we add?

The NLopt installation instructions here https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/algorithms/optimizers/nlopts/__init__.py are outdated and should be updated. I see NLopt is now on pypi (which it was not when that was originally written).  We can probably reduce the install instructions to saying to use `pip install nlopt` but keep the nlopt links in case they are needed,

This was originally noted here https://stackoverflow.com/questions/74218587/unable-to-install-nlopt-for-qiskit


Discussion:
If this is to be updated, we can also update the brief installation remarks returned by the `HAS_NLOPT` optional checker documented here: https://github.com/Qiskit/qiskit-terra/blob/d030145fb467d090e49a85205cd988a2fdbc76ff/qiskit/utils/optionals.py#L101-L104 and defined here:
https://github.com/Qiskit/qiskit-terra/blob/d030145fb467d090e49a85205cd988a2fdbc76ff/qiskit/utils/optionals.py#L270-L275

*edit*: If the NLOpt installation process is much easier now, it may be worth removing the NLOpt-specific callback in the lazy loader too.  I originally added that just to retain exact parity with the previous state of the library, but it may well not be necessary now?  That's a question for the algorithms team, I think - I certainly don't know the context.
ha, I've just spotted my mental localisation failures in the first code sample above - "nonlinear optimi**s**ation library"

Resolving patch:
diff --git a/qiskit/algorithms/optimizers/__init__.py b/qiskit/algorithms/optimizers/__init__.py
--- a/qiskit/algorithms/optimizers/__init__.py
+++ b/qiskit/algorithms/optimizers/__init__.py
@@ -102,15 +102,7 @@
 Global Optimizers
 =================
 The global optimizers here all use NLopt for their core function and can only be
-used if their dependent NLopt package is manually installed. See the following
-section for installation instructions.
-
-.. autosummary::
-    :toctree: ../stubs/
-
-    nlopts
-
-The global optimizers are as follows:
+used if their dependent NLopt package is manually installed.
 
 .. autosummary::
    :toctree: ../stubs/
diff --git a/qiskit/algorithms/optimizers/nlopts/__init__.py b/qiskit/algorithms/optimizers/nlopts/__init__.py
--- a/qiskit/algorithms/optimizers/nlopts/__init__.py
+++ b/qiskit/algorithms/optimizers/nlopts/__init__.py
@@ -1,6 +1,6 @@
 # This code is part of Qiskit.
 #
-# (C) Copyright IBM 2018, 2020.
+# (C) Copyright IBM 2018, 2022.
 #
 # This code is licensed under the Apache License, Version 2.0. You may
 # obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -10,45 +10,4 @@
 # copyright notice, and modified files need to carry a notice indicating
 # that they have been altered from the originals.
 
-"""
-.. _installing-nlopt:
-
-Installing NLopt
-================
-
-In order to use any of the NLOpt based global optimizers NLopt must be installed.
-The `NLopt download and installation instructions
-<https://nlopt.readthedocs.io/en/latest/#download-and-installation>`__
-describe how to do this.
-
-If you running on Windows, then you might want to refer to the specific
-`instructions for NLopt on Windows
-<https://nlopt.readthedocs.io/en/latest/NLopt_on_Windows/>`__.
-
-If you are running on a Unix-like system, first ensure that your environment is set
-to the Python executable for which the Qiskit package is installed and running.
-Now, having downloaded and unpacked the NLopt archive file
-(for example, ``nlopt-2.4.2.tar.gz`` for version 2.4.2), enter the following commands:
-
-.. code:: sh
-
-    ./configure --enable-shared --with-python
-    make
-    sudo make install
-
-The above makes and installs the shared libraries and Python interface in `/usr/local`.
-To have these be used by Qiskit, the following commands can be entered to augment the dynamic
-library load path and python path respectively, assuming that you choose to leave these
-entities where they were built and installed as per above commands and that you
-are running Python 3.6:
-
-.. code:: sh
-
-    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64
-    export PYTHONPATH=/usr/local/lib/python3.6/site-packages:${PYTHONPATH}
-
-The two ``export`` commands above can be pasted into the ``.bash_profile`` file in the user's
-home directory for automatic execution.  Now you can run Qiskit and these optimizers should be
-available for you to use.
-
-"""
+""" NLopt based global optimizers """
diff --git a/qiskit/utils/optionals.py b/qiskit/utils/optionals.py
--- a/qiskit/utils/optionals.py
+++ b/qiskit/utils/optionals.py
@@ -99,9 +99,8 @@
         format.  There are converter methods on :class:`.DAGCircuit` if NetworkX is present.
 
     * - .. py:data:: HAS_NLOPT
-      - `NLOpt <https://nlopt.readthedocs.io/en/latest/>`__ is a nonlinear optimisation library,
-        used by the global optimizers in :mod:`.algorithms.optimizers`.  See installation details in
-        :ref:`installing-nlopt`.
+      - `NLopt <https://nlopt.readthedocs.io/en/latest/>`__ is a nonlinear optimization library,
+        used by the global optimizers in the :mod:`.algorithms.optimizers` module.
 
     * - .. py:data:: HAS_PIL
       - PIL is a Python image-manipulation library.  Qiskit actually uses the `pillow
@@ -253,26 +252,7 @@
 )
 HAS_NETWORKX = _LazyImportTester("networkx", install="pip install networkx")
 
-
-def _nlopt_callback(available):
-    if not available:
-        return
-    import nlopt
-
-    _logger.info(
-        "NLopt version: %s.%s.%s",
-        nlopt.version_major(),
-        nlopt.version_minor(),
-        nlopt.version_bugfix(),
-    )
-
-
-HAS_NLOPT = _LazyImportTester(
-    "nlopt",
-    name="NLopt Optimizer",
-    callback=_nlopt_callback,
-    msg="See the documentation of 'qiskit.algorithms.optimizer.nlopts' for installation help",
-)
+HAS_NLOPT = _LazyImportTester("nlopt", name="NLopt Optimizer", install="pip install nlopt")
 HAS_PIL = _LazyImportTester("PIL.Image", name="pillow", install="pip install pillow")
 HAS_PYDOT = _LazyImportTester("pydot", install="pip install pydot")
 HAS_PYLATEX = _LazyImportTester(


Test patch: