前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >debian用户指定Python版本

debian用户指定Python版本

作者头像
py3study
发布2020-01-02 17:52:38
1.5K0
发布2020-01-02 17:52:38
举报
文章被收录于专栏:python3python3python3

创建命令alias

安装好debian后系统可能会自带多个python版本,在不改变系统默认设置的前提下我们可以给当前用户通过建alias的方式指定python版本

  • 查看当前系统已有的Python版本
dqeric@debian:~$ ll /usr/bin/python*
lrwxrwxrwx 1 root root       9 1月  24  2017 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root       9 1月  24  2017 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3779512 11月 25  2017 /usr/bin/python2.7
lrwxrwxrwx 1 root root       9 1月  20  2017 /usr/bin/python3 -> python3.5
-rwxr-xr-x 2 root root 4747120 1月  19  2017 /usr/bin/python3.5
-rwxr-xr-x 2 root root 4747120 1月  19  2017 /usr/bin/python3.5m
lrwxrwxrwx 1 root root      10 1月  20  2017 /usr/bin/python3m -> python3.5m
  • 查看默认版本
dqeric@debian:~$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
  • 查看当前用户配置文件
dqeric@debian:~$ cat .bashrc 

可以看到下面配置, 这个就是放alias的单独配置文件

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
  • 新建或在已有文件中添加配置后为
dqeric@debian:~$ cat .bash_aliases 
# add alias
alias python='/usr/bin/python3.5'
  • 激活配置后测试Python版本
dqeric@debian:~$ . ~/.bashrc 
dqeric@debian:~$ python
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-10-16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 创建命令alias
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档