I want to run a python script from within IntelliJ IDEA passing a file list as a parameter. I'm using menu Run->Edit Configurations->Script Parameters to define a file list using wildcards like: "../examples/*.jpg"
Inside the code I'm iterating the file list using a for loop like
for f in sys.argv[1:]:
Although the script executes fine from terminal, IDEA throws a file not found exception:
No such file or directory: '../examples/*.jpg'
I suppose this makes sense (my theory) since there is no shell involved to expand the command line argument into a file list prior passing it to the script.
There is an answer in a similar question here: Pycharm and sys.argv arguments The relevant answer using wildcards is https://stackoverflow.com/a/41003295/7521854 but it is not working. (If I had enough rep I'd commented on this answer, sorry)
Any suggestion will make me happy!
PS: running OSX 10.11.6 (El Capitan)
Expanding wildcards in the command line parameters is the feature of the command line shell / terminal. IDE doesn't use the command line shell when starting your application, therefore parameters are not expanded. Related request:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With