LoginSignup
1
2

More than 5 years have passed since last update.

WSLでwxPythonを使う

Last updated at Posted at 2018-03-22

wxPythonを利用しているプログラムをWSL(Windows Subsystem for Linux)上のUbuntuで実行したくて試行錯誤したメモ。

Ubuntu側でpythonプログラム実行してWindows側のXServerで表示します。

前提条件

以下が導入済み
Windows Sybsystem for Linux(Ubuntu、Bash)
python3
pip3

X環境を整える

この項は参考文献をなぞっています。
参考文献はRuby用なので不要な部分についてはカットしています。

X Serverのインストール(Windows側)

VcXsrvを利用しましたが、好きなもので構いません。
https://sourceforge.net/projects/vcxsrv/files/vcxsrv/

X11のインストール(Ubuntu側)

sudo apt update
sudo apt install x11-apps x11-utils x11-xserver-utils

DISPLAY設定

echo 'export DISPLAY=localhost:0.0' >> ~/.bashrc
source ~/.bashrc

動作確認

Windows側でX Serverを起動した状態でUbuntu側で以下のコマンドを実行

xeyes &

wxPythonのインストール

pip3 install --upgrade pip
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython

pip3 install wxPythonでは依存の解決が面倒だったが公式の記述通りに行うことでスムーズにインストールできた

動作確認

Windows側でX Serverを起動した状態でhelloworldを実行

hello.py
import wx; a=wx.App(); wx.Frame(None, title="Hello World").Show(); a.MainLoop()
python3 hello.py

空のwindowが表示されればインストール完了

参考文献
https://qiita.com/fukuramikake/items/283b817c16725af79a28
https://kokufu.blogspot.jp/2018/03/linux-wxpython.html
https://www.wxpython.org/pages/downloads/
https://www.wxpython.org/pages/overview/#hello-world

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