1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PyCallを使ってRubyからPythonを実行する

Posted at

実現したいこと

RubyでPythonのライブラリを使いたい

手順

1. pyenvを使ってる場合

env PYTHON_CONFIGURE_OPTS='--enable-shared' pyenv install 3.9.12

2. 必要なライブラリがあればインストール

pip install package

または

pip install requirements.txt

3. Pycallを追加

gem 'pycall'
bundle install

または

gem install pycall

4. PyCallをロード

require 'pycall/import'
include PyCall::Import

5. Pythonライブラリをimportして使う

pyimport :math
p math.degrees(math.pi / 2)
pyfrom 'pdf2docx', import: 'parse'
parse(pdf_file_path, docx_file_path)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?