简体   繁体   中英

How to add virtualenv to IBM cloud with Python

I'm trying to add sentry to my project to capture errors. To use sentry I need to install raven with pip install raven .

The problem is when I want to upload it to IBM as ibm function .

As the docs says I need to upload .zip file with all .py files that I use including virtualenv .

If I do it as follows (including all in virtualenv):

zip -r ascrawler.zip venv __main__.py common.py db.py

the zip file is bigger than allowed 48MB.

Thus following the tutorial here , I can add only those virtualenv packages that I need. Thus I did it as follows:

zip -r ascrawler.zip venv/bin/activate_this.py venv/lib/python3.6/site-packages/raven venv/lib/python3.6/site-packages/raven-6.9.0.dist-info __main__.py common.py db.py

But when I try to invoke that function with:

ibmcloud wsk action invoke --result ascrawler --param make Audi --param model A3 --param mileage 2500

I get an error that raven couldn't be found:

.....
<module>",
"2018-07-04T12:55:56.590718898Z stderr: from raven import Client", "2018-07-04T12:55:56.590724452Z stderr: ModuleNotFoundError: No module named 'raven'"

Any idea what I do wrong?

There are one (small) error stopping this example from working.

  • Folder containing virtualenv files must be virtualenv and not venv .

The Python runtimes checks for the existance of that directory name to instantiate the user-included modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM