Bash别名->Python 2.7至Python 3.3 [英] Bash alias --> Python 2.7 to Python 3.3

查看:62
本文介绍了Bash别名->Python 2.7至Python 3.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Python 3.4.2设置为Linux的默认设置(当前为2.7.6).我对这方面的知识不是很了解,但是我已经在线阅读了多个地方的内容,您可以在〜/.bashrc 〜/.bash_aliases 文件中简单地添加一个别名像这样:

I am trying to make Python 3.4.2 the default in Linux (currently it is 2.7.6). I am not very knowledgeable on this stuff, but I have read in several places online that you can simply put an alias in the ~/.bashrc or ~/.bash_aliases file like this:

alias python='python3'

我没有〜/.bashrc 〜/.bash_aliases 文件...我假设您可以创建它们.我已经做到了,但是别名似乎没有用.我想念什么吗?您是否需要文件开头的shebang?我已经尝试过两种方式.

I don't have either the ~/.bashrc or ~/.bash_aliases file . . . I am assuming you can just create them. I have done that, but the alias doesn't seem to be working. Am I missing something? Do you need the shebang at the beginning of the file? I have tried it both ways.

感谢您提供的任何帮助!

Thanks for any help you can give!

推荐答案

不要这样做!

某些linux实用程序当前依赖于 python2.x .如果您进行更改,则可能会破坏您的系统,因为 python3.x python2.x 不向后兼容.除非您完全意识到后果,否则不要这样做!

Some linux utilities depend on python2.x currently. It will probably break your system if you make that change since python3.x is not backward compatible with python2.x. Unless you are fully aware of the consequences, don't do it!

在这里提出类似的问题:

Similar question is asked here : https://askubuntu.com/questions/103469/how-do-i-change-my-pythonpath-to-make-3-2-my-default-python-instead-of-2-7-2

这篇关于Bash别名->Python 2.7至Python 3.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆