Ubuntu16.04 already has its own pinyin input method, which can be used directly by setting. The setting method:
1、system setting -》language support -> keyboard input method system 选择 fcitx。
2、system setting -》 text entry -》,勾选 show current input source in the menu bar