Skip to content
Advertisement

IBM Cloud Functions – “Invalid virtualenv. Zip file does not include activate_this.py”

I want to deploy a python script with a virtual environment (I need a library which is not in the runtime provided by IBM Cloud Functions) to IBM Cloud Functions. I want to do this with simple zipping so I followed the documentation: Packaging Python code with a local virtual environment in a compressed file in the link below: https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep

I have python 3.7 installed and the virtualenv also uses that. The virtualenv is named “virtualenv” as required, however I still receive the error when I try to invoke the action: Results:

{
  "error": "The action failed to generate or locate a binary. See logs for details."
}
Logs:
[
  "2021-05-20T09:27:03.627094Z    stderr: Invalid virtualenv. Zip file does not include activate_this.py",
  "2021-05-20T09:27:03.627Z       stderr: The action did not initialize or run as expected. Log data might be missing."
]

I checked the virtualenv directory and I have “activate_this.py” in the Scripts folder.

What am I missing? The only difference between the steps I take and the documentation is that I have a windows computer, so the activation of the environment went like virtualenvScriptsactivate, not through bin, and I zipped the script and the virtualenv via windows GUI.

Is it possible that Cloud Functions tries to find the file in a “bin” folder instead of a “Scripts”? If so, what can I do?

Thanks

Advertisement

Answer

This is a bug in handling windows packaged venv, as you noted. It is fixed in this fork https://github.com/nimbella-corp/openwhisk-runtime-python/commit/2eb3422cb2dca291cff47ed3239de8512170a1be you can apply and build your own container image as a workaround.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement