Search code examples
pythonpip

no such option: --platform linux-x86-64 when running pip install --platform


I get an error:

no such option: --platform linux-x86-64

when using: python -m pip install --platform linux-x86-64.

python -m pip --version shows 24.2.

python -m pip install --help shows --platform argument in the list.

I can't find literally any results on Google, is there anything I am doing fundamentally wrong?

For context full command looks like this:

python -m pip install -r requirements.txt --only-binary=:all: --target ./python_example_app --platform linux-x86_64


Solution

  • no such option: --platform linux-x86-64

    This error message implies that the entire string --platform linux-x86-64 is being treated as a single argument. The --platform flag and its argument value (linux-x86_64) should be passed as separate arguments.

    This may occur, for example, if you run the command in a shell with this full argument in quotes. To fix this, make sure the flag and its argument are passed separately, (for example, without quotes) as you have written in your question.

    $ pip install [...] "--platform linux-x86_64"  # Bad
    # no such option: --platform linux-x86_64
    
    $ pip install [...] --platform linux-x86_64  # Good
    

    The same principle applies if this command is invoked via something like subprocess.run or similar kind of exec call. You should ensure that the --platform flag and its respective argument are passed separately.

    Alternatively, flags and their values can be passed as a single argument when using the form of key=value for example:

    pip install [...] "--platform=linux-x86_64" # this is OK too