Search code examples
amazon-web-servicespipcronserverless

no such option --system for pip install


I'm attempting to deploy a very basic trading system to AWS using serverless (following along with this link), but I have a bit of a problem.

Prior to running the deployment command, I'm supposed to run

pip3 install -r requirements.txt -t . --system

but I am getting an error message saying 'no such option: --system'

Initially, I just tried to install the packages without the --system option, but I think that's causing the cron lamda(??) function to fail when I execute it manually through the serverless console because it's not finding the requisite modules.

I'm assuming it's because they aren't being installed properly so my question is how then should I install them so this doesn't happen?

Running

pip3 install -r requirements.txt

alone (while in the trading system directory) does not suffice.

So, what should I do?


Solution

  • The original author was working on an older Debian-derived system, you aren't. You can safely omit this option if it's not supported.

    I don't have an authoritative link available, although this came up in a Google search. But here's my summary:

    • With older Debian-derived systems (eg, Ubuntu 18.04), the --user flag was enabled by default and it overrode the -t flag, so all packages would be installed in the $HOME/.local. The --system flag was nominally intended to allow installation in the system package directory, but in practice it was needed to enable -t.
    • This is fixed for Debian-derived systems that default to Python 3 (eg, Ubuntu 20.04).
    • It was never an issue for non-Debian systems (eg, EC2 Linux).

    Since you don't seem to be familiar with pip, the -r argument tells it to use a file containing dependencies, and the -t argument tells it to install those dependencies in the current directory (not a great habit, but I don't want to describe virtual environments).