The consumer price index rose for the first time in four months in July, the Labor Department said Friday.