I tried everything in This question
I can’t get the virtual environment to use the installed packages.
virtualenv yielded a “command not found” error
the following .sh file will run and ostensibly install the packages when running
doctl serverless deploy
set -e #virtualenv virtualenv python3 -m venv virtualenv source virtualenv/bin/activate sudo pip3 install -r requirements.txt --target virtualenv/lib/python3.9/site-packages deactivate
but getting “No module found” errors at runtime.
Documentation for functions is lackluster at best. How can it be so difficult to simply install requirements?
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!
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.
Click below to sign up and get $200 of credit to try our products over 60 days!
The answer from my colleague that you linked is the correct approach, but I do notice that it’s a bit out of date. We now recommend customers exclude dependencies like pip from the virtual env.
Check out https://github.com/digitalocean/sample-functions-python-jokes for an example. Note the file https://github.com/digitalocean/sample-functions-python-jokes/blob/master/packages/joke/joke/build.sh in particular.
We have heard feedback that it could use more information. We’re working on updates right now. Feel free to give feedback about docs using our official feedback platform too (https://ideas.digitalocean.com/).
Regarding the function you’re trying to deploy here, feel free to respond here or open a support ticket if it’s still not working for you after following the example I linked.