Running Python in a Ruby environment

Hello,

I’ve developed a Rails application which happens to use a Python script in a background process. (No other way to do this unfortunately).

I added pip install -r requirements.txt to the build command and the dependency installation is successful as evident by the build logs.

However within both the Python script and the SSH console trying to access these dependencies fails with typical “ModuleNotFoundError: No module named ‘’” errors.

Is there a trick to getting this to work, or will I have to extract the Python logic into a separate API to call from the Rails app?

Thanks in advance

If you do pip show Package can you see where the packages have been installed?

I haven’t tried to do this myself, but I imagine using a Dockerfile to install things instead of letting Render see this is a Ruby project and then adding to the build command will be the way forward. At the very least this will give you a repeatible way to test the issue locally.

You will either need to run it under a separate service specifically running the ‘Python’ runtime, or use Docker to install both Ruby and Python runtimes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.