[Contribute Advice] 系统安装后默认是python3.x多好
Tofloor
poster avatar
Li xiang
deepin
2021-06-05 19:04
Author

现在的系统装好后是python2.7,还要自己重新下载安装anaconda,这个不太友好,现在2.7已经停止维护了,什么时候默认是3.X呀?

Reply Favorite View the author
All Replies
忘记、过去
deepin
2021-06-05 19:45
#1

python3 就是......python2 算是系统底层吧,不会随便丢掉的。

Reply View the author
bluesky_
deepin
2021-06-05 19:46
#2

系统自带2.7和3.7,使用python3即可调用,pip对应Python2,pip3对应python3,基本上命令都是对应的,后面加个3即可

Reply View the author
安洛
deepin
2021-06-05 19:49
#3

系统自带python3的,只不过pyhon命令指向python2而已。用python3命令就能调用python3了。

Reply View the author
deepinuser17
deepin
2021-06-05 19:53
#4

深度已经自带了Python 3.7.   安装Python 3.7, 然后把系统默认的Python改成Python 3.7就行了.

 

具体步骤如下:

# 安装Python3

sudo apt install python3 python3-pip


# 查看Python命令文件:

$ ls /usr/bin/python* -lh
lrwxrwxrwx 1 root root    7 Dec 18 20:56 /usr/bin/python -> python2
lrwxrwxrwx 1 root root    9 Dec 18 20:56 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3.3M Feb 25 22:12 /usr/bin/python2.7
lrwxrwxrwx 1 root root    9 Dec 18 20:56 /usr/bin/python3 -> python3.7
-rwxr-xr-x 2 root root 4.7M Apr  1 22:20 /usr/bin/python3.7
-rwxr-xr-x 2 root root 4.7M Apr  1 22:20 /usr/bin/python3.7m
lrwxrwxrwx 1 root root   10 Dec 18 20:56 /usr/bin/python3m -> python3.7m


# 设定系统默认Python为Python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

# 修改默认Python以后, 查看默认Python的版本:
$ which python
/usr/bin/python
$ python --version
Python 3.7.3

 

在Python2和Python3之间切换默认Python, 可以运行这个命令:

sudo update-alternatives --config python

 

如果所有同一机器上的用户都默认使用Python 3, 这个方法是最简单, 方便的.

Reply View the author
观摩
deepin
2021-06-05 21:29
#5

目前的底层很多依赖python2,所以,不能粗暴的处理,需要底层先迁移到python3才可以。

Reply View the author
yorun
deepin
2021-06-05 21:36
#6

还是一句话 系统python不要动,用pyenv安装你想要的python版本,pipenv配合pyenv安装的版本搭虚拟环境,我现在系统pip只安装一个pipx,pipx用来安装python工具,如 ipython/thefuck/black等,开发就能虚拟环境,工具和开发环境都能和系统的隔离开

---

而且会发现python这一套抄js作业,pyenv-nvm、pipenv-npm/yarn、pipx-npx

切到js开发发现熟悉的配方,和系统版的隔离确实省心又方便,随便掰也不怕掰坏环境

 

Reply View the author
陈思煜
deepin
2021-06-06 00:22
#7

你自己写项目别用系统的自带Python  要自己用venv创建一个

Reply View the author
roy_lz
deepin
2021-06-14 01:27
#8

楼上说的都对,系统自带了2和3,用的时候自己区分就好了。

Reply View the author