gpt4 book ai didi

python - 我应该将我的默认 python 版本更改为最新的 python 版本吗?

转载 作者:太空宇宙 更新时间:2023-11-04 03:25:11 25 4
gpt4 key购买 nike

我的系统默认安装了 Python 2.7.9 :-

amitwebhero@AmitKali:~$ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

并且我已经安装了它的最新版本 Python 3.5。

amitwebhero@AmitKali:~$ python3.5
Python 3.5.0+ (default, Oct 11 2015, 09:05:38)
[GCC 5.2.1 20151003] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

但是每当我想在终端中编译 python 程序时,我都需要编写 python3.5 file_name.py ,所以我想更改我的默认 python 版本。

但是我已经安装了基于 python 2.7.9 的插件和程序,所以我怀疑如果我将 python 3.5 设置为默认值,那么它可能会导致我使用以前版本的 python 安装的所有插件出现问题。

如果可能,请尝试告诉我是否应该更改我的默认 python?

最佳答案

首先,它取决于操作系统。对于 Windows - 也许你可以。那里应该没有太多对 Python 的依赖。

但我想你运行的是基于 linux 的操作系统。

例如,对于 centos,您可能会破坏 yum 包管理器 - 据我所知它仍然依赖于 Python2。 Ubuntu 也有很多依赖于 P2 的软件包,尽管他们计划从 16.04 开始迁移到 P3。

为了方便您的工作,您可以添加以下行作为您的 .py 文件的第一行:

#!/usr/bin/env python3

使您的 .py 文件可执行:chmod a+x 并且您可以在没有解释器名称的情况下简单地运行它。

关于python - 我应该将我的默认 python 版本更改为最新的 python 版本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33341310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com