run Python script got error: error: unrecognized arguments

created at 06-27-2021 views: 852


Run the Python program with a script and pass parameters, and an error is reported: error: unrecognized arguments:

The content of the script is as follows:

#!/usr/bin/env bash
python --env_name = "Ant-v2" --actor_path = "./models/Ant/sac_actor_Ant" \
--critic_path =  "./models/Ant/sac_critic_Ant"

The code prompts the error as follows:

usage: [-h] [--env_name ENV_NAME] [--actor_path ACTOR_PATH]
               [--critic_path CRITIC_PATH] [--policy POLICY] [--eval EVAL]
               [--gamma G] [--tau G] [--lr G] [--alpha G]
               [--automatic_entropy_tuning G] [--seed N] [--batch_size N]
               [--num_steps N] [--hidden_size N] [--updates_per_step N]
               [--start_steps N] [--target_update_interval N]
               [--replay_size N] [--cuda] error: unrecognized arguments: Ant-v2 ./models/Ant/sac_actor_Ant critic_path = ./models/Ant/sac_critic_Ant


The reason for the error is that the bash file has added an equal sign, delete it, as shown below, and it can run normally.

#!/usr/bin/env bash
python --env_name  "Ant-v2" --actor_path "./models/Ant/sac_actor_Ant" \
--critic_path  "./models/Ant/sac_critic_Ant"
created at:06-27-2021
edited at: 06-28-2021: