## 1. Install the released version ##
Check docker.md for more details on Docker container image usage, e.g. pulling the development version and running in a shell or Jupyter server. via conda / mamba
conda as:
```bash
conda install -c conda-forge mintpy
```
or via mamba as:
```bash
mamba install -c conda-forge mintpy
```
via docker
via apt (Linux Debian)
Click to expand for more details
a. Download source code
Run the following in your terminal to download the development version of MintPy:
```bash
cd ~/tools
git clone https://github.com/insarlab/MintPy.git
```
b. Install dependencies via conda
Install miniconda if you have not already done so. You may need to close and restart the shell for changes to take effect.
```bash
# use wget or curl to download in the command line or click from the web browser
# for macOS, use Miniconda3-latest-MacOSX-x86_64.sh instead.
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/tools/miniconda3
~/tools/miniconda3/bin/conda init bash
```
Install the dependencies into a custom existing environment [recommended] by running:
```bash
# To create a new custom environment, e.g. named "insar", run "conda create --name insar; conda activate insar"
# To speedup, try "conda install mamba", then use "mamba install" to replace "conda install" below
# Add "gdal'>=3'" below to install extra dependencies if you use ARIA, FRInGE, HyP3 or GMTSAR
# Add "isce2" below to install extra dependencies if you use ISCE-2
conda install -c conda-forge --file ~/tools/MintPy/requirements.txt
```
Or install the dependencies to a new environment, e.g. named "mintpy", by running:
c. Install MintPy
via pip [recommended]
site-packages directory), thus, one could "edit" the source code and have changes take effect immediately without having to rebuild and reinstall.
```bash
python -m pip install -e ~/tools/MintPy
```
via path setup
\~/.bash_profile for bash users or \~/.cshrc for csh/tcsh users:
```bash
if [ -z ${PYTHONPATH+x} ]; then export PYTHONPATH=""; fi
export MINTPY_HOME=~/tools/MintPy
export PATH=${PATH}:${MINTPY_HOME}/src/mintpy/cli
export PYTHONPATH=${PYTHONPATH}:${MINTPY_HOME}/src
```
Install Xcode with command line tools, if you have not already done so. Install Install MintPy via conda, which is the same as the instruction for Linux.
Click to expand for more details
Xcode from App storecommand line tools within XCode and agree to the terms of license.xcode-select --install -s /Applications/Xcode.app/Contents/Developer/
sudo xcodebuild -licenseOr install MintPy via MacPorts
~/.bash_profile file:
```bash
# MacPorts Installer addition on 2017-09-02_at_01:27:12: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:${PATH}
export MANPATH=/opt/local/share/man:${MANPATH}
# Finished adapting your PATH environment variable for use with MacPorts.
```
Update the port tree with the following command. If your network prevents the use of rsync or svn via HTTP of the port tree, try Portfile Sync via a Snapshot Tarball.
```
sudo port selfupdate
```
Install the dependencies by running the following:
```bash
# install dependencies with macports
# use "port -N install" to use the safe default for prompt questions
sudo port install $(cat MintPy/docs/ports.txt)
# install dependencies not available on macports: pysolid, pykml, pykdtree, pyresample, cdsapi
sudo -H /opt/local/bin/pip install git+https://github.com/insarlab/PySolid.git
sudo -H /opt/local/bin/pip install git+https://github.com/insarlab/PyAPS.git
sudo -H /opt/local/bin/pip install git+https://github.com/tylere/pykml.git
sudo -H /opt/local/bin/pip install git+https://github.com/storpipfugl/pykdtree.git
sudo -H /opt/local/bin/pip install git+https://github.com/pytroll/pyresample.git
sudo -H /opt/local/bin/pip install git+https://github.com/ecmwf/cdsapi.git
```
Click to expand for more details
pip install approaches are recommended, as the path setup approach is not tested.
WEATHER_DIR: Optionally, if you defined an environment variable named WEATHER_DIR to contain the path to a directory, MintPy will download the GAM files into the indicated directory. Also, MintPy will look for the GAM files in the directory before downloading a new one to prevent downloading multiple copies if you work with different datasets that cover the same date/time.
#### b. Dask for parallel processing ####
We recommend setting the temporary-directory in your Dask configuration file, e.g. ~/.config/dask/dask.yaml, by adding the following line, to avoid the potential workspace lock issue. Check the dask.md file for more details on parallel processing.
```yaml
temporary-directory: /tmp # Directory for local disk like /tmp, /scratch, or /local
# If you share the same machine with others, use the following instead to avoid permission issues.
# temporary-directory: /tmp/{replace_this_with_your_user_name}
```
#### c. Extra environment variables setup ####
We recommend setting the following environment variables, e.g. in your ~/.bash_profile file, to avoid occasional errors with GDAL VRT and HDF5 files I/O.
```bash
export VRT_SHARED_SOURCE=0 # do not share dataset while using GDAL VRT in a multi-threading environment
export HDF5_DISABLE_VERSION_CHECK=2 # suppress the HDF5 version warning message (0 for abort; 1/2 for printout/suppress warning message)
export HDF5_USE_FILE_LOCKING=FALSE # request that HDF5 file locks should NOT be used
```
#### d. Tab complete sub-commands ####
We recommend activating the tab completion as below if you:
1. Use bash or zsh shells
2. On Linux or macOS
3. Run MintPy in sub-commands style, e.g. mintpy view instead of view.py
```bash
activate-global-python-argcomplete --user
```
On macOS, there is a bash version compatibility issue, which can be fixed as below. If you use the default zsh shell, no fix is needed.
Click to expand for more details
echo $BASH_VERSION to check the version number), but argcomplete requires the newer version (>=4.2), which can be installed using Homebrew as:
```bash
brew install bash
```
You will also need to add the bash to /etc/shells and change your shell via chsh as:
```bash
echo "/usr/local/bin/bash" | sudo tee -a /etc/shells
chsh -s "/usr/local/bin/bash"
```
Then run activate-global-python-argcomplete --user again. You may need to add the following to your ~/.bash_profile file.
```bash
# bash completion
if [ -f ~/.bash_completion ]; then
. ~/.bash_completion
fi
```