WSL2+docker+go+py+vscode 开发环境搭建

WSL2开发环境搭建

WSL2 安装

安装 windows terminal

  • 商店搜索安装
  • 推荐工具 MobaXterm

启用

  • 运行 ubuntu
  • powershell 执行 wsl

更新源

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
sudo apt update
sudo apt upgrade

安装go

wget -O go.tar.gz https://studygolang.com/dl/golang/go1.16.6.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go.tar.gz
sudo ln -s /usr/local/go/bin/go /usr/bin/go
sudo apt install -y unzip make gcc build-essential
echo "export GOPROXY=https://goproxy.cn" >> ~/.bashrc

安装 py

# 自带 py3.8
sudo apt install -y python3-pip
sudo ln -s /usr/bin/python3 /usr/bin/python
# python换源
mkdir -p ~/.pip/
echo '[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = mirrors.aliyun.com' > ~/.pip/pip.conf
# 常用组件
pip install --user --no-cache-dir pandas flask launchpadlib msgpack cx_Oracle SQLAlchemy paramiko redis psycopg2-binary xmltodict py_smtp color_log PyYAML pyecharts pipreqs twine openpyxl xlrd xlwt waitress pymysql py_ctp

安装 oracle

# 安装 oracle 19 client
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-devel-19.9.0.0.0-1.x86_64.rpm
## 工具
sudo apt install alien -y
sudo alien -i ./oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
sudo alien -i ./oracle-instantclient19.9-devel-19.9.0.0.0-1.x86_64.rpm

echo 'export ORACLE_HOME="/usr/lib/oracle/19.9/client64"
export TNS_ADMIN="$ORACLE_HOME/network/admin"
export LD_LIBRARY_PATH="$ORACLE_HOME/lib"
export PATH="$ORACLE_HOME/bin:$PATH"' >> ~/.bashrc

安装 Docker

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
sudo service docker start

Win 开发环境搭建

oracle

官方链接 Oracle Software Downloads | Oracle

1. 下载解压
https://download.oracle.com/otn_software/nt/instantclient/1911000/instantclient-basic-windows.x64-19.11.0.0.0dbru.zip
2. 添加 instantclient 目录到path

mingw

mingw64 管理员运行 避免cgo错误
1. 在线安装工具:
https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe
2. 安装选项:x86_64/ posix/ seh
3. 添加 bin 目录到 path
4. 测试:gcc -v

Go

连接 Go下载 - Go语言中文网 - Golang中文社区 (studygolang.com)

1. 下载安装
https://studygolang.com/dl/golang/go1.16.5.windows-amd64.msi
2. 添加 bin 目录到 path

Python

官方链接 Download Python | Python.org

1. 下载安装
https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe
2. 添加 path
	2.1 python 例 D:\Python38\
	2.2 Scripts  例 D:\Python38\Scripts
3. 换源加速
	3.1 建 pip 目录
		mkdir ~\AppData\Roaming\pip
	3.2 cd ~
	3.3 notepad ~\AppData\Roaming\pip\pip.conf
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
4. 升级 pip
python -m pip install --upgrade pip
5. 常用组件
pip install --user --no-cache-dir pandas flask launchpadlib msgpack cx_Oracle SQLAlchemy paramiko redis psycopg2-binary xmltodict py_smtp color_log PyYAML pyecharts pipreqs twine openpyxl xlrd xlwt waitress pymysql py_ctp

Git

官方链接 Git - Downloads (git-scm.com)

下载安装 https://github.com/git-for-windows/git/releases/download/v2.32.0.windows.2/Git-2.32.0.2-64-bit.exe

GitExtensions

官方链接 Releases · gitextensions/gitextensions · GitHub

安装 vscode

官方链接 Download Visual Studio Code - Mac, Linux, Windows

  • 提速方法
更新网站地址
https://az764295.vo.msecnd.net/stable/c3f126316369cd610563c75b1b1725e0679adfb3/VSCodeSetup-x64-1.58.2.exe
更新后的地址为:http://vscode.cdn.azure.cn/stable/...
这个就是国内的镜像了点开后你会发现速度直接起飞。

安装插件

  • Remote-WSL
  • One Dark Pro
  • VSCode Great Icons
  • Bracket Pair Colorizer 2
  • Go / Install tools
  • Py / Pylance
  • Markdown Preview Enhanced
  • YAML
  • Rainbow CSV
  • Docker

QA

powershell 管理员

# 无法加载 D:\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
> get-executionpolicy
> set-executionpolicy remotesigned
输入 y
上一篇:MVN:settings.xml


下一篇:maven学习01-基本使用