Youcef LAIDANI
Youcef LAIDANI

Reputation: 59986

pip install package in the same folder as the script

I use Atom to create a Python Script, my script use some packages like requests, sendgrid and others..

To install this packages I use:

pip3 install requests

But this command install this package somewhere in windows, but my requirement is to package my script and this libraries to use them as an aws lambda.

My question: is there any way in Atom to package this with my script, or is there any command line to put this libraries in the same folder as my script and then I zip the folder? or what is the correct way to solve this issue?

Upvotes: 1

Views: 1586

Answers (3)

keithRozario
keithRozario

Reputation: 406

I'm guessing you want to package this so you can use the package in the lambda function. This won't work if you've got a windows, because the Lambda function runs on a linux container (or sometimes it might work for pure python packages).

A more sustainable option is to use something like Klayers, you can set the preferred package as a layer for your function and it'll work.

Another option is to use the python serverless requirements package for the serverless framework. https://www.serverless.com/plugins/serverless-python-requirements/

Upvotes: 1

Youcef LAIDANI
Youcef LAIDANI

Reputation: 59986

I find the solution in the aws documentation:

I just used:

$ pip install --target 'C:\path-to-project\my-project' requests

Upvotes: 2

Adrian
Adrian

Reputation: 51

You should be able to use:

pip install --ignore-installed --install-option="--prefix=$YOUR-PATH" requests

The --ignore-installed flag is used to install other dependencies as well, even if those are already installed in the python packages folder.

Upvotes: 0

Related Questions