Forums

Cannot import jsonpickle in Flask

Hello, I want to use jsonpickle to serialize some data, I did pip install jsonpickle --user. I can import in command line, can also execute a python script with import jsonpickle. But once I did import jsonpickle in Flask app, I got import error. I am confused why it does not work. Thank you.

2018-12-05 21:09:53,962: Error running WSGI application 2018-12-05 21:09:53,962: ModuleNotFoundError: No module named 'jsonpickle' 2018-12-05 21:09:53,963: File "/var/www/veridis_pythonanywhere_com_wsgi.py", line 16, in <module> 2018-12-05 21:09:53,963: from flask_app import app as application # noqa 2018-12-05 21:09:53,963: 2018-12-05 21:09:53,963: File "/home/veridis/mysite/flask_app.py", line 8, in <module> 2018-12-05 21:09:53,963: from library import get_field 2018-12-05 21:09:53,963: 2018-12-05 21:09:53,963: File "/home/veridis/mysite/library.py", line 4, in <module> 2018-12-05 21:09:53,964: import jsonpickle

Your website is using Python 3.6; "pip install --user jsonpickle" will have installed the package for Python 2.7. If you use "pip3.6" instead, that will install the package for the right version. See this help page for more information.

Thank you, I used pip3 install jsonpickle --user last time. Look like pip3 is linked to python 3.7. I did it with pip3.6 install jsonpickle --user, it works now. Thank you.

Excellent -- thanks for confirming!