WSL python記錄
1、WSL啟動虛擬機設置:
啟動hyper V + 子系統
2、ubuntu下執行
sudo apt-get install python3-pip
sudo apt-get install python3
3、pip3 工具庫的管理工具
更改下載源
1、安裝:pip install 庫名 -i https://pypi.tuna.tsinghua.edu.cn/simple
2、下載:pip download 庫名 -i 鏡像源
pip默認下載第三方庫的網站是Python官方模塊庫:https://pypi.python.org。但有時網速比較慢,我們可以更換國內的鏡像源。
-
新版ubuntu要求使用https源,要注意。
-
清華:https://pypi.tuna.tsinghua.edu.cn/simple
-
阿里云:http://mirrors.aliyun.com/pypi/simple/
-
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
-
華中理工大學:http://pypi.hustunique.com/
-
山東理工大學:http://pypi.sdutlinux.org/
-
豆瓣:http://pypi.douban.com/simple/
4、查看版本號
python --version
pip3 -V
5、打包生成可執行程序
pyinstaller -F xxx.py
會生成build, dist, __pycache__ 三個目錄,新生成的可執行程序在 dist 目錄里。
******安裝 pyinstaller 后,可能遇到 找不到命令。原因:pyinstaller 命令沒有加載環境變量,系統只加載了~/.bashrc,未加載~/.profile。
6、VScode 使用WSL遇到的問題:VS Code server for WSL closed unexpectedly check WSL terminal for more details

同時,cmd 提示“參考的對象類型不支持嘗試的操作”。
解決辦法:使用管理員權限打開powershell 然后執行下面的語句重置網絡就可以了
netsh winsock reset

浙公網安備 33010602011771號