No module named error when importing installed libraries

Trying to deploy a python script as Function, this script has dependencies. Using the sample code (, I can deploy my script as long as I don’t import any of the dependencies.

If I try to import library that was successfully installed I get this error 2022-10-05T19:04:10.385463002Z stderr: Invalid action: No module named 'pdfrw'

import os, json, sys
import pdfrw
from datetime import date

def main(args):
      name = args.get("name", "stranger")
      greeting = "Hello  " + name + "!"
      return {"body": os.getcwd() + ':' + os.environ['PATH']}

set -e
virtualenv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt



Result from

created virtual environment in 3727ms"
 creator CPython3Posix(dest=/tmp/slices/builds/fn-0c691d34-dc60-4292-a56b-be4aa0adddbe/sample_hello..."
 seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data..."
 added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2"
 activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshAc..."
Collecting pdfrw"
 Downloading pdfrw-0.4-py2.py3-none-any.whl (69 kB)"
Installing collected packages: pdfrw"
Successfully installed pdfrw-0.4"
WARNING: You are using pip version 21.1.2; however, version 22.2.2 is available."
"You should consider upgrading via the '/tmp/slices/builds/fn-0c691d34-dc60-4292-a56b-be4aa0adddbe/sa..."

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.

Pinned Answer

I found the problem. I had to use virtualenv as the name instead of venv