Windows 10 Python running from WSL Ubuntu 20 and Xwindows in VSCode

Опубликовано: 02 Ноябрь 2024
на канале: Lethcode
3,826
33

Steps used to get this setup working.

1) Setup WSL
In depth instructions at https://docs.microsoft.com/en-us/wind...
A) Start Powershell as Admin
B) run the command
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
C) I am only installing WSL1 so here you need to restart

2) Install a Linux Distro
A) Go to https://aka.ms/wslstore
B) I choose Ubuntu 20.04 you can choose what you want you will have to adjust future steps according to your distro though.
C) set up admin user/password

3) Install VSCode if you don't have it already
A) https://code.visualstudio.com/
B) Download and install the Windows build

4) Run VSCode from Ubuntu shell
A) Start your Linux shell with one of the following
a) open a cmd/powershell prompt type wsl
b) Find the app in the start menu
c) Shift right click in a folder Open Linux Shell here
B) Start VScode from Linux with the command
code .
5) Check for VSCode plugins
A) Linux Remoting
B) Python

6) Ubuntu has Python3 set by default

//https://stackoverflow.com/questions/4...
7) Get Pip and other dependencies
A) sudo apt-get update
B) sudo apt-get upgrade
C) sudo apt-get install python3.8-tk (match your python version)
D) sudo apt-get install python3-pip
D) pip3 install matplotlib (optional if you want to use it)


8) Setup VcXsrv from https://sourceforge.net/projects/vcxsrv/
A) after installed run XLaunch
B) In the settings make sure to tick Disable access control, or it may not work
C) Once it is launched it should just sit in the windows system tray waiting for XWindows

9) in .bashrc update add the line, use \\wsl$ to find your distro
mine was at \\wsl$\Ubuntu-20.04\home\{profile}\.bashrc
export DISPLAY=localhost:0.0

10) Restart your Ubuntu Bash
Either run a python graphic program, linux xwindow app or python script that creates a xwindow

Get 2 FREE Audio Books from Audible
https://amzn.to/2ZfViDn

My Favorite Books on Coding, Devops, and Leadership

The Phoenix Project https://amzn.to/3ahITFm
The Unicorn Project https://amzn.to/2NtIKFD
The Devops Handbook https://amzn.to/3jMG6al
The Infinite Game https://amzn.to/3b9AjHO
Start With Why https://amzn.to/3pf6jPS
Clean Code https://amzn.to/3b2dOEU
Code Complete https://amzn.to/2NtIYMZ

Gear Used
Blue Snowball iCE USB Mic https://amzn.to/2ZiPpVT
Intel Core i5-10600KF - 8GB Memory - NVIDIA GeForce GTX 1660 SUPER - 1TB HDD + 240GB SSD
https://amzn.to/2ZeZT91

Davinci Resolve - Editing
StreamLabs OBS - Screen Capture

**Disclaimer: Lethcode is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to www.amazon.com.