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。但有时网速比较慢,我们可以更换国内的镜像源。

  1. 新版ubuntu要求使用https源,要注意。

  2. 清华:https://pypi.tuna.tsinghua.edu.cn/simple

  3. 阿里云:http://mirrors.aliyun.com/pypi/simple/

  4. 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

  5. 华中理工大学:http://pypi.hustunique.com/

  6. 山东理工大学:http://pypi.sdutlinux.org/

  7. 豆瓣: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

 

posted @ 2022-04-07 09:33  Brickert  Views(81)  Comments(0Edit  收藏  举报