ubuntu部署python环境,vscode编辑wsl项目遇到的问题汇总

​ Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-*解决办法 ​

pip install --upgrade pip

主要是pip的版本低的原因。

ubuntu系统apt-get安装python-devel命令

apt-get -y --force-yes install python-dev

mysql和mysql-devel安装

sudo apt install mysql-server

sudo apt-get install libmysqld-dev

更新openssh服务

// 卸载
sudo apt-get remove openssh-server
// 安装
sudo apt-get install openssh-server
// 编辑配置文件// vim /etc/ssh/sshd_config    
    Port 36022  # 默认的是22,但是windows有自己的ssh服务用的也是22端口,修改一下
    UsePrivilegeSeparation no
// 重启ssh服务
sudo service ssh --full-restar

配置中有一项PasswordAuthentication, 改为yes可以使用密码登录,这里我们使用ssh秘钥对登录,所以使用默认no

Win10 WSL Ubuntu 根目录实际位置

1. 运行(win+R),直接输入 \\wsl$ 进入Ubuntu的目录。

2. 或者文件夹里同样输入  \\wsl$ 进行查找。

ubuntu部署python环境,vscode编辑wsl项目遇到的问题汇总_第1张图片

更新Ubuntu的源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo vim /etc/apt/sources.list

清华源

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

中科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

阿里源

deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
sudo apt-get update

sudo apt-get upgrade

在执行sudo apt-get upgrade命令之后有时候会提示The following packages were automatically installed and are no longer required.
也就是按照字面意思之后的包已经不被需要了,这个时候就可以把这些包清除掉从从而来节约空间

清除这些包的代码如下

sudo apt-get autoremove

然后输入‘y’即可清除

The following packages have been kept back:

有部份packages的安装版比release版新而出现”The following packages have been kept back”这个问题,解决方法是使用

apt-get -u dist-upgrade

统一更新到发布的版本。这条命令会强制更新软件包到最新版本,并自动解决缺少的依赖包。

安装pip

sudo apt install python3-pip

安装env

sudo apt install python3-venv

创建项目环境

 我是在/opt/code 下创建的虚拟目录

sudo python3 -m venv aishare 

cd /opt/code/aishare/bin

source activate #进入虚拟目录

安装django

which python #看看python在个目录下

/opt/code/aishare/bin/python  -m pip install django #安装django

配置 vscode for wsl 开发环境

alias code="/mnt/d/Program\ Files/Microsoft\ VS\ Code/Code.exe"

code . #这个是让vscode 打开当前目录

chown -R wb /opt/code/ #给code目录赋予权限,让vscode可以编辑保存。wb是我的主机的名字

你可能感兴趣的:(python,ubuntu)