时间:2021-05-22
你可以按照以下方法使用 ls 命令来查看你的系统中都有那些 Python 的二进制文件可供使用。
执行如下命令查看默认的 Python 版本信息:
$ python --versionPython 2.7.81、基于用户修改 Python 版本:
想要为某个特定用户修改 Python 版本,只需要在其 home 目录下创建一个 alias(别名) 即可。打开该用户的 ~/.bashrc文件,添加新的别名信息来修改默认使用的 Python 版本。
alias python='/usr/bin/python3.4'一旦完成以上操作,重新登录或者重新加载 .bashrc 文件,使操作生效。
$ . ~/.bashrc检查当前的 Python 版本。
$ python --versionPython 3.4.22、 在系统级修改 Python 版本
我们可以使用 update-alternatives 来为整个系统更改 Python 版本。以 root 身份登录,首先罗列出所有可用的 python 替代版本信息:
# update-alternatives --list pythonupdate-alternatives: error: no alternatives for python如果出现以上所示的错误信息,则表示 Python 的替代版本尚未被 update-alternatives 命令识别。想解决这个问题,我们需要更新一下替代列表,将 python2.7 和 python3.4 放入其中。
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode# update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode--install 选项使用了多个参数用于创建符号链接。最后一个参数指定了此选项的优先级,如果我们没有手动来设置替代选项,那么具有最高优先级的选项就会被选中。这个例子中,我们为 /usr/bin/python3.4 设置的优先级为2,所以update-alternatives 命令会自动将它设置为默认 Python 版本。
# python --versionPython 3.4.2接下来,我们再次列出可用的 Python 替代版本。
# update-alternatives --list python/usr/bin/python2.7/usr/bin/python3.4现在开始,我们就可以使用下方的命令随时在列出的 Python 替代版本中任意切换了。
# update-alternatives --config python# python --versionPython 2.7.83、移除替代版本
一旦我们的系统中不再存在某个 Python 的替代版本时,我们可以将其从 update-alternatives 列表中删除掉。例如,我们可以将列表中的 python2.7 版本移除掉。
# update-alternatives --remove python /usr/bin/python2.7update-alternatives: removing manually selected alternative - switching python to auto modeupdate-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode方法2、移除软连接
rm -rf /data/logsln -s /temp/logs /data/logs解决软连接ln报错-bash: /usr/local/bin/mysql: Too many levels of symbolic links
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
Python跟Python3完全就是两种语言1、importcaffeFAILED 环境为Ubuntu16cuda8.0NVIDIA361.77Anaconda
python怎么区分不同数据类型?Python判断变量的数据类型的两种方法一、Python中的数据类型有数字、字符串,列表、元组、字典、集合等。有两种方法判断一
1.Anaconda安装python3.6condacreate-nmatchpython=3.6Python版本默认安装是3.6.92.安装opencv执行完
pycharm部署anaconda环境Pycharm:python编辑器,社区版本Anaconda:开源的python发行版本(专注于数据分析的python版本
1.概述本文记录在Ubuntu16.04上将python升级为3.8版本,并配置为系统默认python3的过程。在Ubuntu16.04中,python3的默认