Functional Dev basic python dev app -> non-functional in production server

13 views
Skip to first unread message

Liam Laing

unread,
Jan 27, 2021, 6:19:44 AM1/27/21
to sandst...@googlegroups.com
Kia ora,
I am currently looking into packing sandstorm applications. I am starting with python applications using a diy initial set up.
I got a basic web server running in development mode after setting the home value as recommended in the stumbles section on python spk raw packing tutorial.

But when I package it and pop it on a production server I get the following error:

Could not find platform independent libraries <prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Fatal Python error: Py_Initialize: Unable to get the locale encoding LookupError: no codec search functions registered: can't find encoding

I am a little befuddled by the issue and have been stuck with the issue for a while now.

Any ideas on how to go about tracking down the issue?

Final note, this is a fantastic project! :-)

Ngā mihi,

Liam

Jacob Weisz

unread,
Jan 27, 2021, 8:23:19 AM1/27/21
to sandst...@googlegroups.com
(Specifically, I believe that the virtualenv is what negates the need for PYTHONHOME.)

Additionally, if you want to use PYTHONHOME, you can set environment variables in an app's package definition file. An example of that is here: https://github.com/sandstorm-io/collections-app/blob/master/sandstorm-pkgdef.capnp#L97

--
  Jacob Weisz

--
You received this message because you are subscribed to the Google Groups "Sandstorm Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sandstorm-de...@googlegroups.com.

Troy Farrell

unread,
Jan 27, 2021, 12:28:11 PM1/27/21
to Sandstorm Development
Hello Liam!

We're glad to hear that you're packaging an app for Sandstorm.  I have lots of experience with this, both with the diy and uwsgi stacks.  Unless you've done something with Debian's site.py or you are using a custom build of Python, you probably want something like this in your .sandstorm/launcher.sh file:

PYTHONUSERBASE=/tmp "$VENV"/bin/python /opt/app/path/to/my/script.py

Debian's site.py will use PYTHONUSERBASE to bypass the error that you experienced.  Note that my suggestion above assumes that you've created a virtualenv and have set its path in the VENV variable.  Let me know if this doesn't solve your problem.

Good luck!
Troy
Reply all
Reply to author
Forward
0 new messages