Skip to content
Advertisement

Passing arguments to an entry point python script using argparser

I am looking to pass a user entered arguments from the command line to an entry point for a python script. Thus far I have tried to used argparse to pass the arguments from the command line to the test.py script. When I try to pass the arguments they are not recognised and I recieve the following error.

load_entry_point(‘thesaurus==0.1’, ‘console_scripts’, ‘thesaurus’)()
TypeError: find_synonym() missing 1 required positional argument: ‘argv’

I have looked at other examples on here but have not been able to get any of the solutions to work.

JavaScript

My setup.py script entry point looks like the following

JavaScript

What I expect to happen is similar to when I run python main.py main foo. Which will successfully print out hello when it is passes to the function.

Advertisement

Answer

So it works now when I remove the the arguments from the function.

JavaScript

I believe that it might work with the sys.arv used in the first example, as my actual problem was that when I re-downloaded this script from GitHub using.

pip install git+ URL

The script was not updating so the error persisted, This required deleting all the files related to the GitHub repository and re-installing it using the same pip command.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement