更改Ubuntu下默认Python版本
更改Ubuntu下默认Python版本
首先查看系统内有哪些版本的Python
ls /usr/bin/python*
查看当前python版本
python --version
基于用户修改默认版本
- 想要为某个特定用户修改 Python 版本,只需要在其 home 目录下创建一个 alias(别名) 即可。打开该用户的 ~/.bashrc文件,添加新的别名信息来修改默认使用的 Python 版本。
alias python='/usr/bin/python3.6'
- 一旦完成以上操作,重新登录或者重新加载 .bashrc 文件,使操作生效。
. ~/.bashrc
在系统级修改 Python 版本
- 使用 update-alternatives 来为整个系统更改 Python 版本。以 root 身份登录,首先罗列出所有可用的 python 替代版本信息:
update-alternatives --list python
update-alternatives: error: no alternatives for python
- 如果出现以上所示的错误信息,则表示 Python 的替代版本尚未被 update-alternatives 命令识别。想解决这个问题,我们需要更新一下替代列表,将 python2.7 和 python3.6 放入其中。
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
- --install 选项使用了多个参数用于创建符号链接。最后一个参数指定了此选项的优先级,如果我们没有手动来设置替代选项,那么具有最高优先级的选项就会被选中。这个例子中,我们为 /usr/bin/python3.6 设置的优先级为2,所以update-alternatives 命令会自动将它设置为默认 Python 版本。
python --version
此时查看版本已经是python 3.6
- 接下来,我们再次列出可用的 Python 替代版本。
update-alternatives --list python /usr/bin/python2.
/usr/bin/python3.- 现在开始,我们就可以使用下方的命令随时在列出的 Python 替代版本中任意切换了。
update-alternatives --config python
移除替代版本
- 一旦我们的系统中不再存在某个 Python 的替代版本时,我们可以将其从 update-alternatives 列表中删除掉。例如,我们可以将列表中的 python2.7 版本移除掉。
update-alternatives --remove python /usr/bin/python2.
- 方法2、移除软连接
rm -rf /data/logs ln -s /temp/logs /data/logs
更改Ubuntu下默认Python版本的更多相关文章
- 关于Ubuntu的默认python版本
大部分Ubuntu系统默认python版本都是python2.x系列,但最新版本已经是3.5和3.6了,软件系统跟着版本走总是有诸多好处的,所以,以下是作者在修改Ubantu默认python版本时的一 ...
- Ubuntu修改默认Python版本,你了解多少~
目录 1 查看Python版本 1.1 查看装有哪些版本 1.2 查看默认版本 2 修改Python默认版本 2.1 基于文件修改 2.2 基于软链接修改 1 查看Python版本 1.1 查看装有哪 ...
- 修改ubuntu的默认python版本
ubuntu14.04LTS上装有两个版本的python:python2.7.6与python3.4,默认使用python2.7.6. 可以使用以下命令来修改默认python版本: sudo cp / ...
- ubuntu配置默认python版本并安装pip
ubuntu 16.04本身是自带python的,他本身是自带2.X和3.X,两个版本,默认的是2.X.这里记录一下如果在版本间切换以及如何把python版本切换到3.X下的方法. 1.查看Ubunt ...
- ubuntu设置默认python版本
原文:https://www.cnblogs.com/johnny1024/p/8400511.html ··· ubuntu 16.04本身是自带python的,他本身是自带2.X和3.X,两个版本 ...
- ubuntu 切换默认python版本
现在的python项目都是基于python3的了,再用ubuntu的时候默认的版本是py2的,所以想切换到py3上: 打开终端: sudo update-alternatives --install ...
- 指定linux 下默认python版本
sudo rm -rf python sudo ln -s /usr/bin/python3 /usr/bin/python
- Linux系统更改默认Python版本
Linux 默认的Python版本为Python2.X,但是在很多时候我们需要使用Python3.X,那么我们需要更改Linux的默认Python版本,更改很简单,只需要两句话. sudo updat ...
- 更改Ubuntu默认python版本的方法
当你安装 Debian Linux 时,安装过程有可能同时为你提供多个可用的 Python 版本,因此系统中会存在多个 Python 的可执行二进制文件.一般Ubuntu默认的Python版本都为2. ...
随机推荐
- deployment.yaml 带同步时区
[root@lab2 dandang]# cat dandang.v1.yaml apiVersion: v1 kind: ReplicationController metadata: name: ...
- 【Leetcode_easy】917. Reverse Only Letters
problem 917. Reverse Only Letters solution: class Solution { public: string reverseOnlyLetters(strin ...
- 高级UI-自定义Behavior
Behavior本身是一个抽象类,可以用于两个view之间的状态监听,也可用于某个view监听CoordinateLayout里面的所有控件滑动状态,实现自定义Behavior则可以实现任意两个vie ...
- js删除json指定元素
var obj = {‘id’:1, ‘name’:‘张三’}; delete obj.id; // 或者 delete obj[id];
- win10卸载office2010的工具
本来想装一个高版本的office,于是想先卸载老版本的.结果在win10的应用和功能中,愣是没找到安装的office2010,使用360也找不到,没法卸载. 网上搜了一下,找到一个好工具,micros ...
- va_start(),va_end()函数应用
原理解释: VA_LIST 是在C语言中解决变参问题的一组宏,在<stdarg.h>头文件下. VA_LIST的用法: (1)首先在函数里定义一具VA_LIST型的变 ...
- HashMap的key存储对象需要注意哪些
HashMap的key最好不要存储对象,大部分环境都是String. 如果要存储对象,要注意重写下equal和hashcode方法!!
- js18位身份证验证(非原创)
原文链接 function check_id(value) { var arrExp = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];/ ...
- LeetCode 792. 匹配子序列的单词数(Number of Matching Subsequences)
792. 匹配子序列的单词数 792. Number of Matching Subsequences 相似题目 392. 判断子序列
- [Visual Studio] - 使用 Fiddler 时,禁止监控 VSHub 请求的方法
背景 VS + Fiddler 调试 WebAPI,监控请求包含大量 VSHub Request.http://localhost:49161/vshub/bb195f2e0d5c4765b9411f ...