LoginSignup
0
2

More than 1 year has passed since last update.

python embed インストール

Last updated at Posted at 2022-08-04

■ python embedded インストール

[1] python.exe のあるフォルダで setenv.batを作成して実行
PYTHON_PATHの箇所は実際にpythonEmbedをおいたフォルダ名に編集 (※ %DP0% は変えない)
参考:
↓全体手順
https://hituji-ws.com/code/python/python-emb-usage/
Windowsでpythonを使う/配布する時に便利!Python embeddable package使い方

 例:変更後
 SET PYTHON_PATH=%DP0%\PythonEmbed395

[2] get-pip.py をダウンロードして、python.exeのあるフォルダで実行する
  https://bootstrap.pypa.io/

[2]-2 実行は python get-pip.py コマンド

[2]-3 pythonXX_.pth の編集
   import siteの前についている #を消す

[3]current.pth ファイルを python.exeのあるフォルダに作成する
【対応方法】
Pythonをインストールしたフォルダ内に「current.pth」というファイルを作成します。
作成した「current.pth」をメモ帳などで開いてimport sys; sys.path.append('')と記載して保存します。

参考:
↓全体手順
https://hituji-ws.com/code/python/python-emb-usage/
Windowsでpythonを使う/配布する時に便利!Python embeddable package使い方

↓current.pthについて
https://qiita.com/rhene/items/68941aced93ccc9c3071
Windowsで環境を極力汚さずにPythonを動かす方法 (Python embeddable版)

Pythonは特に意識しなくてもカレントディレクトリに存在するPythonファイルをimportできるのですが、embeddable版ではパスが通らずアクセスできない状態になっています。
自分でコードを書く分にはそれほど問題になりませんが、TensorFlowなどをpipでインストールする際にエラーでコケる場合があります。
そこで、下記の方法でカレントディレクトリにパスを通すことで、問題を回避します。

↓参考まで(使用なし)
https://qiita.com/mm_sys/items/1fd3a50a930dac3db299


■ Tkinter の追加
参考:
https://qiita.com/Neilus/items/17b44d737d5acd1982fb

ただし tkinterはLib直下でなく、 Lib/sitepackages に置く。
(例 C:\PythonEmbed395\Lib\site-packages )

0
2
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
0
2