I tried with the name and the slug and different menus but I always
find that error.
Did you try with location slug? Take a look at where your menu location is defined (functions.php), for example:
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'mytheme' ),
) );
On Appearance->Menus assign your menu to that location.
And then run your code starting with:
$menu_name="primary";