You have upgraded to macOS High Sierra and found this error while trying to upgrade macports via command line?
fmbp:~ florian$ sudo port -v selfupdate Error: Current platform "darwin 17" does not match expected platform "darwin 16" 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 High Sierra version and install it.
as normal, after the macports installation you have to upgrade the packages and sometimes you can get compile errors. If this is the case for you, follow the migration instructions.
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