升级系统自带Python到3.0的版本
Tofloor
poster avatar
buffly
deepin
2017-08-29 16:46
Author
咱们系统自带的是Python2.7.13,想问一下升级到3.0会不会对系统造成什么影响
Reply Favorite View the author
All Replies
avatar
jingle
deepin
2017-08-29 16:59
#1
需要把仓库中没有明显标注使用python2的软件进行修改并重新打包,对我们的程序没有影响
基本上很多底层功能和脚本都会废掉吧,debian那边还在用py2,所以很多东西也都是py2写的
Reply View the author
avatar
jingle
deepin
2017-08-29 17:00
#2
  1. deepin@deepin:~$ apt-cache rdepends python | grep deepin
  2.   deepin-chrome-arc
  3.   python-deepin-utils
  4.   deepin-software-center-data
  5.   deepin-software-center
  6.   deepin-menu
  7.   deepin-gettext-tools
  8.   deepin-game-center
Copy the Code
Reply View the author
avatar
BingoLove
deepin
2017-08-29 17:29
#3
python3并不是python2的升级,而是两个不同的分支

系统应该是已经自带python3了,你终端输入python3就知道了

最好的方法是在程序里面显式指定用的python2还是python3,要不然就是程序编写的时候进行兼容,不过这样会比较麻烦甚至有时候无法实现
Reply View the author
avatar
buffly
deepin
2017-08-29 17:29
#4
https://bbs.deepin.org/post/144792
需要把仓库中没有明显标注使用python2的软件进行修改并重新打包,对我们的程序没有影响
基本上很多底层功能 ...

底层功能和脚本废掉的话那就不升级了
Reply View the author
avatar
iminto
deepin
2017-08-29 17:54
#5
https://bbs.deepin.org/post/144792
底层功能和脚本废掉的话那就不升级了

Linux对Python都有依赖,无法简单升级,不止是Debian,几乎任何Linux系统都无法升级内置Python,比如centos的yum也依赖Python。即使系统不搞坏,应用软件也会被搞坏。

但是,不能升级Python3,不意味着不能安装Python3.只需要手动把Python3安装在一个单独的目录,并且不污染系统的环境变量就可以。一定得手动安装,要是用apt,yum什么的安装,那就等着重装系统吧
Reply View the author
avatar
sinux
deepin
2017-08-29 18:23
#6
https://bbs.deepin.org/post/144792
Linux对Python都有依赖,无法简单升级,不止是Debian,几乎任何Linux系统都无法升级内置Python,比如cento ...

扯什么呢?
Reply View the author
avatar
DebuggerX
deepin
2017-08-29 18:25
#7
https://bbs.deepin.org/post/144792
Linux对Python都有依赖,无法简单升级,不止是Debian,几乎任何Linux系统都无法升级内置Python,比如cento ...

apt的处理就是一个python指向python2.+,一个python3指向python3.+互不影响啊
Reply View the author
avatar
iminto
deepin
2017-08-29 22:22
#8

我没说不能同时使用Python2和Python3吧
Reply View the author
avatar
Feng Yu
deepin
2017-08-29 22:32
#9
直接用anaconda吧,和系统的python隔离开。系统的python不能乱动
Reply View the author
avatar
sinux
deepin
2017-08-29 22:51
#10
https://bbs.deepin.org/post/144792
我没说不能同时使用Python2和Python3吧

你说不能用apt,yum装啊
Reply View the author
avatar
isunny
deepin
2017-08-30 00:31
#11
Python 有一个包管理器 叫做 p 类似 npm 的包管理器 n  , 可以实现 py2 和 py3的共存,
Reply View the author
avatar
陈思煜
deepin
2017-08-30 00:45
#12
deepin的python是两个分支共存的你使用Python2命令就输入python ,pip使用python3命令就python3,pip3来运行就可以了
Reply View the author
avatar
cyden
deepin
2017-08-30 06:46
#13
直接 sudo apt-get install python3.6  就可以。两个版本共存,都能正常使用
Reply View the author
avatar
shaolin-wu
deepin
2018-01-15 17:41
#14

怎么安装的啊,手动安装py3?
Reply View the author
avatar
shaolin-wu
deepin
2018-01-15 17:43
#15
https://bbs.deepin.org/post/144792
直接 sudo apt-get install python3.6  就可以。两个版本共存,都能正常使用

如何切换两个版本呢?
Reply View the author
avatar
Deepin大法好
deepin
2018-01-15 17:59
#16
https://bbs.deepin.org/post/144792
如何切换两个版本呢?

一种方法是运行时制定python版本,比如运行hello.py,想用python2运行的话就python2 hello.py,想用python3运行的话就用python3 hello.py。

另一种方法就是更改全局软链接。
cd /usr/bin
sudo rm python
sudo ln -s python3 python
这样就可以把python3连接为python,以后终端输入python就是打开python3。此时,依赖于python2的软件就无法使用了。
想要切换回来的话,就
cd /usr/bin
sudo rm python
sudo ln -s python2 python
Reply View the author
avatar
comzhong
deepin
2018-01-15 18:11
#17
liaodong2014 发表于 2018-1-15 09:59
一种方法是运行时制定python版本,比如运行hello.py,想用python2运行的话就python2 hello.py,想用pytho ...

开头几句代码检测,如果py2就调用py3打开
Reply View the author
avatar
ih******op@vip.qq.com
deepin
2018-01-15 19:13
#18
  1. sudo apt-get install python3
  2. python3 script.py
Copy the Code
Reply View the author
avatar
joe51392010
deepin
2018-02-28 21:16
#19
sudo apt-get install python-pip  //python2.x的pip;   sudo apt-get install python3-pip //python3.x的pip
Reply View the author
avatar
134******40
deepin
2018-02-28 23:06
#20
系统本身已经自带了python2版本和python3两个版本,默认使用的python2、python3版本想使用必须显性调用或者切换python3版本为默认版本。
Reply View the author