Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAMS is not registered correctly in show-versions #523

Open
glatterf42 opened this issue Mar 22, 2024 · 6 comments
Open

GAMS is not registered correctly in show-versions #523

glatterf42 opened this issue Mar 22, 2024 · 6 comments
Labels
Milestone

Comments

@glatterf42
Copy link
Member

Code sample or context

Recently, @behnam-zakeri tried to install message-ix again on a new Linux machine. The process went fine by creating a new virtual environment via virtualenv and virtualenvwrapper and we made sure that the directory for gams is in $PATH. This can be confirmed by running gams on the system; it seems to work both from the command line and as part of the westeros_baseline tutorial from message-ix. However, running

message-ix show-versions

tells us that 'gams' is not in PATH. Since everything else is working fine, my expectation is that this is due to an issue with the way that ixmp tries to find gams, not about the installation per se.

We should note that the Linux machine was not a fresh install. Things like pip and virtualenv or even venv were missing, which seems odd.

Expected result

message-ix show-versions, which is internally using https://github.com/iiasa/ixmp/blob/d202e019204e6cf979df6f2a827322a00dbd1957/ixmp/model/gams.py#L18C1-L50C20 should find the correct version of gams.

Problem description

It doesn't seem to find it at all.

Versions

@behnam-zakeri If you can edit this description, please add the output of message-ix show-versions here. Otherwise, please just paste it down below.

Output of ixmp show-versions
<!--
Run one of the following and paste the results here:
- 'ixmp show-versions' in a terminal, or
- 'import ixmp; ixmp.show_versions()' in a Python interpreter.
-->
@glatterf42 glatterf42 added the bug label Mar 22, 2024
@glatterf42 glatterf42 added this to the 3.9 milestone Mar 22, 2024
@khaeru
Copy link
Member

khaeru commented Mar 22, 2024

One way to debug this is to put for instance:

    print(os.environ)

    # Execute, capturing stdout
    output = check_output(
        ...
    )

    print(output)

…around the subject code.

Setting PATH can have some subtleties. For instance, if setting the value in .profile or a similar file, the value will appear in all new terminals opened after that addition. But if one has a terminal open prior, and does not do anything in it, then its prior value of PATH is not automatically updated.

@khaeru khaeru modified the milestones: 3.9, 3.10 Jun 4, 2024
@khaeru khaeru modified the milestones: 3.10, 3.11 Feb 26, 2025
@Wegatriespython
Copy link

Hi, I recently tried installing message-ix on my Windows machine and am encountering the same issue. In my PowerShell session, running gams directly works fine (it prints the GAMS version and license info), but when I run message-ix show-versions, it reports that the 'gams' executable is not in PATH—even though it should be.

I've restarted VS Code multiple times, and I’ve seen that this issue was also mentioned in #456.

Below is the output from my PowerShell session:

(messageix_dev) PS V:\Work> message-ix show-versions
'gams' is not recognized as an internal or external command,
operable program or batch file.

ixmp:        3.10.0
message_ix:  3.10.0
message_ix_models: 2024.1.30.dev27+gc22e63d8
     c22e63d8 (HEAD -> leap-re-wks, origin/leap-re-wks) update reporting after Rev 1 bug on elec inv
message_data: 0.0.0
     d15e6abfa (HEAD -> ssp_dev, origin/ssp_dev) Update shipping emissions and harmonize with CEDS inventories (#601)

click:       8.1.8
dask:        2025.2.0
genno:       installed
graphviz:    0.20.3
jpype:       1.5.2
… JVM path:  C:\Program Files\Java\jre1.8.0_441\bin\server\jvm.dll
openpyxl:    3.1.5
pandas:      2.2.3
pint:        0.24.4
xarray:      2025.1.2
yaml:        6.0.2

iam_units:   installed
jupyter:     installed
matplotlib:  3.10.1
plotnine:    0.14.5
pyam:        3.0.0

GAMS:        'gams' executable not in PATH

python:      3.13.2 | packaged by conda-forge | (main, Feb 17 2025, 13:52:56) [MSC v.1942 64 bit (AMD64)]
python-bits: 64
OS:          Windows
OS-release:  11
machine:     AMD64
processor:   AMD64 Family 25 Model 68 Stepping 1, AuthenticAMD
byteorder:   little
LC_ALL:      None
LANG:        en_US.UTF-8
LOCALE:      ('English_Netherlands', '1252')

And here’s the output when I run gams directly:

(messageix_dev) PS V:\Work> gams
--- Job ? Start 03/18/25 16:45:12 49.2.0 9b2b0844 WEX-WEI x86 64bit/MS Windows
***
*** GAMS Base Module 49.2.0 9b2b0844 Mar 5, 2025           WEI x86 64bit/MS Window
***
*** GAMS Development Corporation
*** support@gams.com, www.gams.com
***
*** GAMS Release     : 49.2.0 9b2b0844 WEX-WEI x86 64bit/MS Windows
*** Release Date     : Mar 5, 2025
*** To use this release, you must have a valid license file for
*** this platform with maintenance expiration date later than
*** Feb 15, 2025
*** System Directory : V:\GAMS\49\
***
*** License          : V:\GAMS\49\gamslice.txt
*** Small MUD - 5 User License                     S240905|0002AP-GEN
*** IIASA, Information and Communication Technologies Dep.
*** DC216   01M5CODICLPTMB
*** License Admin: Melanie Weed-Wenighofer, wenighof@iiasa.ac.at
***
*** Licensed platform                             : Generic platforms
*** The installed license is valid.
*** Maintenance expiration date (GAMS base module): Nov 29, 2025
*** Note: For solvers, other expiration dates may apply.
*** Status: Normal completion
--- Job ? Stop 03/18/25 16:45:12 elapsed 0:00:00.004

Any ideas or workarounds for ensuring that message-ix correctly picks up the updated PATH in my VS Code/virtual environment on Windows?

@glatterf42
Copy link
Member Author

Hi @Wegatriespython, thanks for picking this up :)
As you can see, our discussion above stalled, so we don't yet have more information about what's going on and how we could fix this issue.
I see that you installed message-ix-models and message_data from source, so you know how this works. Could I ask you to please also install ixmp and message_ix from source? For this, you might need to start from a fresh virtual environment to make sure no traces of either are left when you start this process. This would allow you to implement what @khaeru suggested above and report back the output, which would then (hopefully) allow us to get to the bottom of this issue :)

@glatterf42
Copy link
Member Author

One more clarifying question: why did you restart VSCode multiple times? You said this error occurs in your PowerShell session, so if you need to restart anything to make sure the changes to your PATH take effect, it would be your PowerShell session, not VSCode.

@glatterf42
Copy link
Member Author

Lastly, if I remember correctly, this discussion stalled because even though message-ix show-versions didn't pick up GAMS correctly, the rest of the code did. So could you please try running one of the tutorials to see if you can actually solve a Scenario?
If you can, you might not need any workaround after all :)

@Wegatriespython
Copy link

I will look into this and return. Ah I was using the integrated terminal in VScode (set to powershell) so I did the restart to ensure the powershell started with a fresh session (tried setting persistent terminal sessions to off).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants