镜像下载:https://cn.ubuntu.com/download/desktop
配置固定IP方式:
Ubuntu18之前在/etc/network/interfaces进行配置,Ubuntu18及之后版本在/etc/netplan/*.yaml进行配置,如/etc/netplan/01-network-manager-all.yaml,如果路径没有该文件,可以新建一个
netstat -rn #查看网关
sudo vim /etc/netplan/01-network-manager-all.yaml
#举例:
network:
version: 2
renderer: NetworkManager
ethernets:
ens33: # 网卡名称
dhcp4: no
dhcp6: no
addresses: [192.168.100.101/24] # 本机ip及掩码
gateway4: 192.168.100.2 # 网关地址
nameservers:
addresses: [192.168.100.2] # DNS跟随网关地址一致,也可以改别的,如[114.114.114.114,8.8.8.8
参考:https://www.shuzhiduo.com/A/kmzLNpKl5G/
yaml文件内容:
network:
version: 2
renderer: NetworkManager
ethernets:
ens37:
dhcp4: no
dhcp6: no
addresses: [192.168.8.155/24]
gateway4: 192.168.8.1
nameservers:
addresses: [8.8.8.8,114.114.114.114]
在配置完yaml文件后执行:
sudo netplan apply # 修改文件后应用该修改
ifconfig #查看
""双引号不会转义字符串里面的特殊字符:特殊字符会作为本身想表达的意思 例:"张三\n李四" 会表示出 张三 然后是一个换行 然后才是 李四, '' 单引号会转义字符串里面的特殊字符
例:'张三\n李四' 表示出来的就是一个字符串 张三\n李四
换源原因:国内有相关的软件源,用国内的源进行下载时可以提高下载效率。
国内源也是比较多的,经常用到的就有:阿里源,清华源,网易源等。
在我的操作中用到了阿里的源:
阿里apt源:https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11YWglBv
换源方式:
deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
其他国内的源:
阿里源 https://developer.aliyun.com/mirror/
清华源 https://mirrors.tuna.tsinghua.edu.cn/
华科源 http://mirrors.ustc.edu.cn/
网易源 http://mirrors.163.com/
清华源:
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.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt-get update
sudo apt-get -f install
sudo apt-get upgrade
sudo apt-get openssh-server
sudo apt-get ssh
sudo apt-get net-tools
参考文章:https://blog.csdn.net/weixin_46048542/article/details/120403339
以下代码不能参照,不要这样卸载原有的python3.6,因为这会导致原有Ubuntu系统的好多功能也被卸载,比如Ubuntu桌面系统和gedit等,慎重慎重
# 1.卸载Python3.6
sudo apt-get remove python3.6
# 2.卸载Python3.6及其依赖
sudo apt-get remove --auto-remove python3.6
# 3.清除python3.6
sudo apt-get purge python3.6
删除python3.6指向python3的软连接,后续的软连接是python3.9->python3的,把原本的pip3重命名。因为pip3是会去/usr/bin/python3去找。
不过这样的方式会引起问题:
sudo apt install -y wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev zlib1g
sudo apt-get install -y wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev zlib1g >install.txt
说明:以上代码的意思:可以通过-y 跳过询问 y/n
apt-get 可以获取deb包到 /var/cache/apt/archives
install.txt 输出重定向到文件内
mkdir /usr/local/python3.9.0 #作为编译后的python软件位置
cd /home/lcy/python3.9.0 #源码位置
./configure --prefix=/usr/local/python3.9.0
sudo make
sudo make install
参考: https://blog.csdn.net/LCY133/article/details/107889704,https://www.jb51.net/article/202175.htm
在执行完 make install后可以查看到/usr/local/python3.9.0/下有相关的库和bin文件,我们需要建立软连接以便将python解释器链接到/usr/bin/python3上,以后执行python3就是执行的python3.9.0,另外就是pip3.9也要与pip3相关联。
ln -s /usr/local/python3.9.0/bin/python3 /usr/bin/python3.9
ln -s /usr/local/python3.9.0/bin/pip3 /usr/bin/pip3
执行python3
执行pip --version
lcy@ubuntu:~$ pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'
可以看到出现了问题,因为这个pip使用的是python3.9的解释器,查看pip3的代码
vim /usr/bin/pip3
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
可以查看到这里用的python3的解释器,也就是原有系统python3.6.9的解释器,需要我们手动更换成python3.9
vim /usr/bin/pip3
#!/usr/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
再次执行pip3 --version,发现已经正常
执行 pip3 install flask
pip3 选择python版本升级:
python3 -m pip install --upgrade pip
在~目录创建.pip目录,进入.pip目录创建pip3.conf文件,写入换源内容,即可实现永久换源
豆瓣的
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
豆瓣:http://pypi.douban.com/simple/
清华的:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
use-mirrors =true
mirrors =https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host =pypi.tuna.tsinghua.edu.cn
阿里的:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
use-mirrors =true
mirrors =http://mirrors.aliyun.com/pypi/simple/
trusted-host =mirrors.aliyun.com
换源后对当前pip3进行升级:
python3.9 -m pip install --upgrade pip
在pycharm的Manage Repositories中添加源地址即可,
subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.
参照博客:
https://blog.csdn.net/qq_41856814/article/details/108714479
删除了文件:/usr/local/lsb_release