sys args are not recognized

Viewed 63

I used to make use of sys args to start my python scripts with additional parameters from the windows command line. For example I would run the following line from my windows commandline:

myscript.py 100 1 1

The Problem: On using print(argv) I only receive the name of the script ['C:\path\myscript.py'], somehow the rest gets omitted. Python 3.6 is in my environment variables.

I cannot detect any differences between the point in time when it worked and now. Even re-installing Python was fruitless. I then installed anaconda, but the result remains the same when I run the following command:

conda run myscript.py 100 1 1 

myscript.py minimal contents which reproduced the behavior for me:

from sys import argv
print(argv)
1 Answers

help docs of conda run

usage: conda run [-h] [-n ENVIRONMENT | -p PATH] [-v] [--dev]
                 [--debug-wrapper-scripts] [--cwd CWD]
                 ...

Run an executable in a conda environment. [Experimental]

Use '--' (double dash) to separate CLI flags for 'conda run' from CLI flags sent to
the process being launched.

Example usage:

    $ conda create -y -n my-python-2-env python=2
    $ conda run -n my-python-2-env python --version

Conda Run is used to run an executable and that executable is python. To run the script we need python and python is the executable.

Hence, you specify python along with the script to run.

Related