Unable to install ampl_module_base (python AMPL API)

I was following Initial Setup — AMPL API 2.0 (amplpy-0.9.3) documentation to install amplpy in python.

Below line runs fine :

Install Python API for AMPL

$ python -m pip install amplpy --upgrade

However, while running the below line, I get an ERROR :

Install HiGHS and Gurobi (AMPL is installed automatically with any solver)

$ python -m amplpy.modules install highs

ERROR

spyder-env ❯ python -m amplpy.modules install highs                                
$ /Users/bawasthi/miniconda3/envs/spyder-env/bin/python -m pip install -i https://pypi.ampl.com ampl_module_base ampl_module_highs
Looking in indexes: https://pypi.ampl.com
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:997)'))': /ampl-module-base/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:997)'))': /ampl-module-base/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:997)'))': /ampl-module-base/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:997)'))': /ampl-module-base/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:997)'))': /ampl-module-base/
Could not fetch URL https://pypi.ampl.com/ampl-module-base/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.ampl.com', port=443): Max retries exceeded with url: /ampl-module-base/ (Caused by SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:997)'))) - skipping
ERROR: Could not find a version that satisfies the requirement ampl_module_base (from versions: none)
ERROR: No matching distribution found for ampl_module_base
Error: Failed to install modules.

Could you please help. Many thanks.

Regards
Bhartendu

Hi @Bhartendu_Awasthi,

Thank you for reporting this issue. Could you please try with the following:

python -m amplpy.modules install highs --trusted-host=pypy.ampl.com

--trusted-host=pypy.ampl.com should tell pip to trust our Python Package Index.

Thanks for your reply.

However, I am still getting the same error:

Could you please try installing the modules as follows:

python -m pip install -i https://portal.ampl.com/dl/pypi ampl_module_base ampl_module_highs

Unfortunately still getting an error:

In a message before I had written --trusted-host=pypy.ampl.com by mistake, when it should have been --trusted-host=pypi.ampl.com. Could you please try with:

python -m amplpy.modules install highs --trusted-host=pypi.ampl.com --trusted-host=portal.ampl.com

Upgrading pip (pip install pip --upgrade) may also eventually fix this issue. It is one of the possible solutions mentioned in: python - pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)" - Stack Overflow

Still does not work. Is there a manual or another alternative way of installing the packages.

You can download the .whl packages manually from Links for ampl-module-base and Links for ampl-module-highs

For instance, for macOS you could download ampl_module_highs-20230227-py3-none-macosx_10_9_universal2.whl and ampl_module_base-20230512-py3-none-macosx_10_9_universal2.whl. You can then install them with:

$ python -m pip install ampl_module_base-*.whl ampl_module_highs-*.whl

Another alternative is to download an AMPL CE bundle, and then point to the AMPL installation directory as follows:

from amplpy import AMPL, add_to_path
add_to_path(r"full path to the AMPL installation directory")
ampl = AMPL()

Regarding the errors you are observing, we were still not able to reproduce them. Is this happening behind some firewall or VPN?

1 Like

It works ! :slight_smile: [used your option 1]. Thank you very much @fdabrandao for your patience in answering my question.
Since its my office machine may be some firewalls were causing some issue (general does not happen).

2 questions:
a) Private Index there are not all solvers especially CP ones : ilogcp and gecode. These get shipped with AMPL installation otherwise. Is there a way to call these solvers via python API ?
b) Does AMPL has any plans to onboard CP-SAT solver by or tools ?

Many thanks again,
Bhartendu Awasthi

1 Like

Hi @Bhartendu_Awasthi,

We have just made gecode and ilogcp available as modules:

Regarding CP-SAT, I believe the issue was the interface being not as generic as other solver interfaces, which would complicate the development of the driver. @Gleb_Belov, is this correct?

1 Like

The CP-SAT API docu is not very verbose but the example seems straightforward: CP-SAT 解題工具  |  OR-Tools  |  Google for Developers, so I think a driver implementation should be similar to other APIs

1 Like

Thank you ! Very helpful.

Thanks for the update.