将linux 2.7上的python更新到3.5 [英] Update python on linux 2.7 to 3.5

查看:172
本文介绍了将linux 2.7上的python更新到3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我按照以下说明更新了python:

So I updated python using these instructions:

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-devlibsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

然后

cd ~/Downloads 
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
tar -xvf Python-3.5.0.tgz
cd Python-3.5.0

然后

./configure
sudo make install



python3.5
Python 3.5.0 (default, Oct  3 2015, 03:16:42) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

它可以工作,但是当我关闭终端并编写时 python -v 仍然是python 2.7,在执行使用v3 +标准库的代码时仍然出现错误

and it worked but when I closed terminal, and wrote python -v it is still python 2.7 and still getting errors executing code that use v3+ standard libraries

如何使其在3.5下工作?

How to make it working as 3.5?

推荐答案

您仍然安装了Python 2,并且python命令仍默认设置为调用该版本. 尝试像这样运行脚本:

You still have Python 2 installed, and the python command is still set up to invoke that version by default. Try running your scripts like this:

python3 yourscriptname.py

在/usr/bin/中,"python"实际上是到python2.7的符号链接.如果您不想每次使用python时都在末尾键入3,请更改该符号链接,使其指向python3.然后python将运行Python 3.5,您可以使用python2.7或仅使用python2来运行Python 2.7脚本.

In /usr/bin/, "python" is actually a symlink to python2.7. If you'd rather not have to type the 3 at the end whenever you use python, change that symlink to point to python3 instead. Then python will run Python 3.5 and you can use python2.7 or just python2 to run Python 2.7 scripts.

这篇关于将linux 2.7上的python更新到3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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