What I got stuck around GUI in WSL python environment

Introduction

I just built a python environment on wsl the other day, and I didn't run a program that included a GUI, so when I tried it, I got stuck with an error, so I'll leave a memorandum of how to deal with it.

Overview of the executed program

What I was trying to run was a GUI program using PyQt5. It also includes drawing with matplotlib. In the Anaconda environment, it is a program that can be executed without any additional settings.

Details of the error

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. When I ran the program, I got the above error.

When I looked it up, there was a person who encountered a similar situation. [\ qt \ .qpa \ .plugin: Could not load the Qt platform plugin" xcb "in" "even though it was found \. \ What to do when the error occurs -Qiita](https: // qiita.com/fukasawah/items/99219e1ff7d08915952f)

What i did

I did the following:

sudo apt install libxkbcommon-x11-0

However, before executing this, the following is carried out.

[^ 1]: How to run Python on Windows without polluting the environment as much as possible \ (Windows 10, version 1607 or later using WSL only ) -Qiita

When executing a program that includes a GUI such as matplotlib, it is necessary to start Xserver. If you run it without starting it, you will get the following error.

qt.qpa.xcb: could not connect to display :0.0 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped) 

There may be unnecessary parts, but in my case this was the solution. For your reference.

Recommended Posts

What I got stuck around GUI in WSL python environment
What I learned in Python
What I did when I got stuck in the time limit with lambda python
What I got from Python Boot Camp
A reminder of what I got stuck when starting Atcoder with python
I got stuck installing Anaconda 4.3.0 which became Python 3.6
[Question] What happens when I use% in python?
How to run GUI programs such as tkinter in Python environment on WSL2
virtual environment in python
[GUI in Python] PyQt5-Dialog-
Development environment in Python
When I tried to use Python on WSL (windows subsystem for linux), it got stuck in Jupyter (solved)
What I do when imitating embedded go in python
When I tried to introduce python3 to atom, I got stuck
What I got into Python for the first time
I got InsecurePlatformWarning in python, so I installed requests [security]
I got stuck when trying to specify a relative path with relative_to () in python
What to do if Sort imports get stuck in VS Code's Python Extension (around 2020/09)
When I made CaboCha usable with python3, I got stuck (Windows 10)
I wrote python in Japanese
Mezzanine introduction memo that I got stuck in the flow
I got an error in vim and zsh in Python 3.7 series
[Django3] Display a web page in Django3 + WSL + Python virtual environment
Handle environment variables in Python
[GUI in Python] PyQt5 -Widget-
5 reasons I got into Python
Introducing GUI: PyQt5 in Python
I understand Python in Japanese!
[GUI in Python] PyQt5 -Event-
I got an AttributeError when mocking the open method in python
What I was addicted to with json.dumps in Python base64 encoding
GUI programming in Python using Appjar
I got lost in the maze
Install scrapy in python anaconda environment
I checked Mac Python environment construction
I got stuck so I reviewed it
I wrote Fizz Buzz in Python
install tensorflow in anaconda + python3.5 environment
I learned about processes in Python
I can't install scikit-learn in Python
I wrote the queue in Python
[GUI in Python] PyQt5-Menu and Toolbar-
Code tests around time in Python
I tried Line notification in Python
I wrote the stack in Python
GUI creation in python using tkinter 2
I set the environment variable with Docker and displayed it in Python
Environment maintenance made with Docker (I want to post-process GrADS in Python
I got stuck in a flask application redirect with a reverse proxy in between
Upload what you got in request to S3 with AWS Lambda Python
[At Coder] What I did to reach the green rank in Python
After all, what should I use to do type comparisons in Python?
I put Python 2.7 in Sakura VPS 1GB.
I tried to implement PLSA in Python
A note where a Python beginner got stuck
GUI creation in python using tkinter part 1
How to access environment variables in Python
I tried to implement permutation in Python
Method to build Python environment in Xcode 6
What I got into when using Tensorflow-gpu
I made a payroll program in Python!