Export (or erlport) issues when deploying

I have some code in my application that calls to a python function (relying on a python library) to convert HTML pages to PDFS. Using the directions in the blog post here i’m able to use export to run a python script in my application in local development.

I’m having issues when it comes to getting the same behaviour on a production server where i deploy using edeliver & distillery. Currently i’m getting an error where it can’t find the module that i’ve defined.

my guess is that it’s because the venv virtual machine isn’t running, but it’s not clear on how to follow those instructions when it comes to distillery releases (starting up a virtual server afterwards for example?).

My Python code is here and the place i’m calling it from is here.

Anyone have experience deploying python code and can point me in the right direction?

    {:ok, py} = Python.start(python_path: Path.expand("lib/python"))

When you do releases, this is not available. You will need to put the python code into your priv folder and then use :code.priv_dir/1 to find it.

2 Likes

Thanks @NobbZ, that got me further along than i was before.

i’m now running into an issue where the program is unable to find the module i’m loading in (weasyprint) when the application is actually running.

However, If i run the application using the console from distillery on the server it has no issues and generates the PDF as expected.

Would it be trying to load python in different ways between these two methods of running the application? my best guess on this is that running server isn’t looking for/finding the correct venv virtual environment while the console is.

Before you started the application, have you sources the environments activation script?