LoginSignup
1
3

More than 1 year has passed since last update.

Embeddable Python環境にfutureライブラリをインストールする.

Posted at

背景

Embeddable Python環境でline-bot-sdkライブラリを利用したかった.
しかし,pip install時に,依存するfutureライブラリのインストールでエラーが出た.
なお,本記事執筆時点でのfutureライブラリのバージョンは0.18.3である.

インストール失敗.log
PS C:\Users\hoge\Downloads\python-3.11.2-embed-amd64> ./python -m pip install future
Collecting future
  Using cached future-0.18.3.tar.gz (840 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\hoge\AppData\Local\Temp\pip-install-ooax0jzt\future_4f17c5ec60354cc08d4df73197500084\setup.py", line 86, in <module>
          import src.future
      ModuleNotFoundError: No module named 'src'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

できたこと

Embeddable Python環境に,futureライブラリ(と,line-bot-sdk)をインストールした.

やったこと

futureライブラリの「setup.py」ファイルに,「sys.path.append("")」と記載した行を追記する.

setup_追記後抜粋.py
#!/usr/bin/env python

from __future__ import absolute_import, print_function

import os
import os.path
import sys

sys.path.append("")  # ←この行を追記した.

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

具体的な手順

  1. PyPIより該当のインストーラをダウンロードする.
  2. 7-Zip等を利用して解凍する.
  3. 適当なテキストエディタでsetup.pyファイルを開き,上記一行を追記する.
  4. ZIPファイルに固め,当該ZIPファイルを指定してpip installする.
インストール成功.log
PS C:\Users\hoge\Downloads\python-3.11.2-embed-amd64> ./python -m pip install ./future-0.18.3.zip
Processing c:\users\hoge\downloads\python-3.11.2-embed-amd64\future-0.18.3.zip
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: future
  Building wheel for future (setup.py) ... done
  Created wheel for future: filename=future-0.18.3-py3-none-any.whl size=492053 sha256=46bd2748826e7eea027eef3bebffb5a3ee23ac940bacba86b85d728cf5895917
  Stored in directory: c:\users\hoge\appdata\local\pip\cache\wheels\5f\f7\ed\dd1ed5930a7bed1e192e75511b90568f6f49717e6d5b24ad7b
Successfully built future
Installing collected packages: future
  WARNING: The scripts futurize.exe and pasteurize.exe are installed in 'C:\Users\hoge\Downloads\python-3.11.2-embed-amd64\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed future-0.18.3

原因考察

「python.exe」の存在する場所にパスが通っていないのが直接的な原因か?
環境変数をあまりいじりたくないので,Embeddable Pythonをパスを通さずに利用していた.
(わざわざEmbeddable Pythonを使う人,そういう人多そう.)
(理解が間違っていたらコメント欄で教えてください.)

参考文献

1
3
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
3