run Python script got error: error: unrecognized arguments

created at 06-27-2021 views: 4

description

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

The content of the script is as follows:

#!/usr/bin/env bash
python main.py --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: main.py [-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]
main.py: error: unrecognized arguments: Ant-v2 ./models/Ant/sac_actor_Ant critic_path = ./models/Ant/sac_critic_Ant

solution

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 main.py --env_name  "Ant-v2" --actor_path "./models/Ant/sac_actor_Ant" \
--critic_path  "./models/Ant/sac_critic_Ant"
Please log in to leave a comment.