You have upgraded to macOS Sierra and found this error while trying to upgrade macports via command line?
fmbp:~ root# port -v selfupdate Error: Current platform "darwin 16" does not match expected platform "darwin 15" Error: If you upgraded your OS, please follow the migration instructions: https://trac.macports.org/wiki/Migration OS platform mismatch while executing "mportinit ui_options global_options global_variations" Error: /opt/local/bin/port: Failed to initialize MacPorts, OS platform mismatch
The error is explaining very well what is happening and the recommendation is to visit the Migration website for further instructions.
My recommendation (and tested of course) is to just download the latest macports, the Sierra version and install it.
In short, you have to do the following:
fmbp:~ root# port -qv installed > myports.txt fmbp:~ root# port echo requested | cut -d ' ' -f 1 > requested.txt fmbp:~ root# port -f uninstall installed fmbp:~ root# port selfupdate fmbp:~ root# port clean all fmbp:~ root# curl -O https://svn.macports.org/repository/macports/contrib/restore_ports/restore_ports.tcl fmbp:~ root# chmod +x restore_ports.tcl fmbp:~ root# ./restore_ports.tcl myports.txt