What is the correct structure for the build file in the lib folder of a serverless function?

I have been implementing serverless functions (python) and would like to implement multiple packages under one app. Each of these functions require access to a separate toolset ( which I’ve placed in the lib folder. Since the toolset requires additional python libraries (psycopg2), I’ve created a requirements.txt file within the lib folder and an associated file.

I have followed the same structure in the tutorials but on compilation, I receive the following error:

╭──────────── project build ───────────╼
│ Started running ./ in /.app_platform_workspace/lib
│ ./ line 5: virtualenv: command not found
│  ›   Error: './' exited with code 127

The code is hosted on Github and remote builds are triggered on repo updates.

What is the correct structure for the file in the lib folder?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 5, 2023

Hi there,

The contents of the lib folder and the contents of each function’s directory affect what is included in each deployed function and how that function is built.

Here is also an example project that might help:

The structure is more or less just the file and your library.

Here is also another example on how this is implemented:

The above is from an end-to-end test and includes a simple use of the lib directory and a file.

If your serverless function repository is public, feel free to share it here and I will be happy to take a further look at why the builds might be failing.



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel