Installation¶
Ensure you have first read the prerequisites for understanding and using MESSAGEix. These include specific points of knowledge that are necessary to understand these instructions and choose among different installation options.
Install system dependencies¶
GAMS (required)¶
MESSAGEix requires GAMS.
Download GAMS for your operating system; either the latest version or, for users not familiar with GAMS licenses, version 29 (see note below).
Run the installer.
Ensure that the
PATH
environment variable on your system includes the path to the GAMS program:on Windows, in the GAMS installer…
Check the box labeled “Use advanced installation mode.”
Check the box labeled “Add GAMS directory to PATH environment variable” on the Advanced Options page.
on other platforms (macOS or Linux), add the following line to a file such as
~/.bash_profile
(macOS),~/.bashrc
, or~/.profile
:$ export PATH=$PATH:/path/to/gams-directory-with-gams-binary
Note
MESSAGE-MACRO and MACRO require GAMS 24.8.1 or later (see MACRO.GAMS_min_version
)
The latest version is recommended.
GAMS is proprietary software and requires a license to solve optimization problems.
To run both the message_ix
and ixmp
tutorials and test suites, a “free demonstration” license is required; the free license is suitable for these small models.
Versions of GAMS up to version 29 include such a license with the installer; since version 30, the free demo license is no longer included, but may be requested via the GAMS website.
Note
If you only have a license for an older version of GAMS, install both the older and the latest versions.
Graphviz (optional)¶
reporting.Reporter.visualize()
uses Graphviz, a program for graph visualization.
Installing message_ix causes the python graphviz
package to be installed.
If you want to use visualize()
or run the test suite, the Graphviz program itself must also be installed; otherwise it is optional.
If you install MESSAGEix Using Anaconda, Graphviz is installed automatically via its conda-forge package. For other methods of installation, see the Graphviz download page for downloads and instructions for your system.
Install MESSAGEix¶
After installing GAMS, we recommend that new users install Anaconda, and then use it to install MESSAGEix.
Advanced users may choose to install MESSAGEix using pip
, or from source code (next sections).
If you are not doing this, then skip those sections.
Using Anaconda¶
Install Python via either Miniconda or Anaconda. 1 We recommend the latest version; currently Python 3.8.
Open a command prompt. Windows users should use the “Anaconda Prompt” to avoid issues with permissions and environment variables when installing and using MESSAGEix. This program is available in the Windows Start menu after installing Anaconda.
Configure conda to install
message_ix
from the conda-forge channel 2:$ conda config --prepend channels conda-forge
Create a new conda enviroment. This step is required if using Anaconda, but optional if using Miniconda. This example uses the name
message_env
, but you can use any name of your choice:$ conda create --name message_env $ conda activate message_env
Install the
message-ix
package into the current environment (eitherbase
, or another name from step 7, e.g.message_env
) 3:$ conda install message-ix
Again: at this point, installation is complete.
You do not need to complete the steps in “Using pip
” or “From source”.
Go to the section Check that installation was successful.
- 1
See the conda glossary for the differences between Anaconda and Miniconda, and the definitions of the terms ‘channel’ and ‘environment’ here.
- 2
The ‘$’ character at the start of these lines indicates that the command text should be entered in the terminal or prompt, depending on the operating system. Do not retype the ‘$’ character itself.
- 3
Notice that conda uses the hyphen (‘-’) in package names, different from the underscore (‘_’) used in Python when importing the package.
Note
When using Anaconda (not Miniconda), steps (5) through (8) can also be performed using the graphical Anaconda Navigator. See the Anaconda Navigator documentation for how to perform the various steps.
Using pip
¶
pip is Python’s default package management system.
If you install Anaconda (step 4, above), then pip
is also usable.
pip
can also be used when Python is installed directly, without using Anaconda.
Ensure
pip
is installed—with Anaconda, or according to the pip documentation.Open a command prompt and run:
$ pip install message_ix
From source¶
Install ixmp from source.
(Optional) If you intend to contribute changes to MESSAGEix, first register a Github account, and fork the message_ix repository. This will create a new repository
<user>/message_ix
. (Please also see Contributing to development.)Clone either the main repository, or your fork; using the Github Desktop client, or the command line:
$ git clone [email protected]:iiasa/message_ix.git # or: $ git clone [email protected]:USER/message_ix.git
Open a command prompt in the
message_ix
directory and type:$ pip install --editable .[docs,reporting,tests,tutorial]
The
--editable
flag ensures that changes to the source code are picked up every timeimport message_ix
is used in Python code. The[docs,reporting,tests,tutorial]
extra requirements ensure additional dependencies are installed.(Optional) If you will be using
MESSAGE_master.gms
outside of Pythonmessage_ix
to run MESSAGEix, you will likely modify this file, but will not want to commit these changes to Git. Set the Git “assume unchanged” bit for this file:$ git update-index --assume-unchanged message_ix/model/MESSAGE_master.gms
To unset the bit, use
--no-assume-unchanged
. See the Git documentation for more details.(Optional) If installed from source, run the built-in test suite to check that MESSAGEix functions correctly on your system:
$ pytest
Check that installation was successful¶
Verify that the version installed corresponds to the latest release by running the following commands on the command line:
# Show versions of message_ix, ixmp, and key dependencies
$ message-ix show-versions
# Show the contents of the default local Platform (empty on install)
$ message-ix --platform=default list
The above commands will work as of message_ix
3.0 and in subsequent versions.
If an error occurs, this may mean that an older version has been installed and should be updated.
To check the current version:
# If installed using conda
$ conda list message-ix
# If installed using pip
$ pip show message-ix
Install rmessageix
¶
rmessageix
is the R interface to MESSAGEix; see R API (rmessageix).
You only need to install rmessageix
if you intend to use message_ix
from R, rather than from Python.
Install MESSAGEix from source, per the previous section. Then:
Open a command prompt in the
message_ix/
directory and type the following commands to build, then install,rmessageix
:$ R CMD build rmessageix $ R CMD INSTALL rmessageix_*.zip
(Optional) Install IRkernel, which allows running R code in Jupyter notebooks (see the link for instructions). Check that the R interface works by using the built-in test suite to run the R tutorial notebooks:
$ pytest -m rmessageix
Common issues¶
Copy GAMS model files for editing¶
By default, the GAMS files containing the mathematical model core are installed
with message_ix
(e.g., in your Python site-packages
directory). Many
users will simply want to run MESSAGEix, or use the Python or R APIs to
manipulate data, parameters and scenarios. For these uses, direct editing of the
GAMS files is not necessary.
To edit the files directly—to change the mathematical formulation, such as adding new types of parameters, constraints, etc.—use the message-ix
command-line program to copy the model files in a directory of your choice:
$ message-ix copy-model /path/for/model/files
You can also set the message model dir
configuration key so that this copy of the files is used by default:
$ message-ix config set "message model dir" /path/for/model/files
…or do both in one step:
$ message-ix copy-model --set-default /path/for/model/files