I'm trying to call a python function in a file in my ruby on rails application.
My python file is located at project_dir/lib/assets/python/the_file.py
I'm utilizing PyCall for ruby with the lines:
require 'pycall'
PyCall.sys.path.append('/lib/assets/python')
file_import = PyCall.import_module("the_file")
I get an error saying
<class 'ModuleNotFoundError'>: No module named 'the_file'
Is it just a syntax error? Is there a better different way I should be trying to run my python script in rails?
I am using ruby 3.0.0, rails 7.0.2, and python 3.11
Use a relative path:
PyCall.sys.path.append('./lib/assets/python')