简体   繁体   English

Linux Mint 更改 Python 的当前版本

[英]Linux Mint Changing current version of Python

I have installed python 3.7 but still using and showing version of python 2.7 .我已经安装了 python 3.7 但仍在使用和显示 python 2.7 的版本。 I want to change it to 3.. I searched it but ı can't did it.我想把它改成 3.. 我搜索过它,但我做不到。

You should not change your syslink python to use python 3 because it is most likely that your system is using that syslink to python 2 for its own tasks and processes, if you change that, you may broke your system.你不应该改变你的 syslink python来使用 python 3,因为你的系统很可能正在使用 python 2 的 syslink 来执行它自己的任务和进程,如果你改变它,你可能会破坏你的系统。

As Sammy said in a comment, you should use python3 to use that version.正如 Sammy 在评论中所说,您应该使用python3来使用该版本。

On the pip side, it is probably that your python 3 does not have pip include (it should have it, but I have seen a lot of Python 3 without it).在 pip 方面,可能是你的 python 3 没有 pip include(它应该有,但我见过很多没有它的 Python 3)。 You can check if you have pip doing: python3 -m pip .你可以检查你是否有 pip 在做: python3 -m pip The -m param is used to execute modules of python installed. -m参数用于执行安装的python 模块。

If you do not have pip installed , you can install it following this (which I recommend because always work): https://pip.pypa.io/en/stable/installing/如果您没有安装 pip ,您可以按照以下方式安装它(我建议这样做,因为它始终有效): https : //pip.pypa.io/en/stable/installing/

That is:那是:

  • Download a script to install pip: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py下载安装pip的脚本: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  • Execute the script in order to install pip (with sudo because you're going to modify your system): sudo python3 get-pip.py执行脚本以安装 pip(使用 sudo,因为您要修改系统): sudo python3 get-pip.py

Now you should have pip installed and doing python3 -m pip again should show you the help of pip.现在你应该已经安装了 pip 并且再次执行python3 -m pip应该会向你展示 pip 的帮助。

If you have pip already installed and no pip3 command in your system, you can always create an alias to python3 -m pip with the name pip3 and problem solved.如果您已经安装了 pip并且您的系统中没有 pip3 命令,您总是可以创建一个名为pip3的别名到python3 -m pip并且问题已解决。 Also if you don't know or do not want to create alias or executables in the /usr/bin folder, you can always keep using python3 -m pip .此外,如果您不知道或不想在 /usr/bin 文件夹中创建别名或可执行文件,您始终可以继续使用python3 -m pip

PS: It is highly recommended to use virtualenvs when developing with python. PS:强烈建议使用python开发时使用virtualenvs。 If you do not know what it is, here it is a link to the docs: https://virtualenv.pypa.io/en/latest/如果您不知道它是什么,这里是文档的链接: https : //virtualenv.pypa.io/en/latest/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM