所以我使用这些说明更新了python:
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 +标准库的代码
如何让它像3.5一样工作?
//安装python 3.6
sudo add-apt-repository ppa:jonathonf/python-3.6 sudo apt update sudo apt install python3.6
//更改默认python
sudo rm /usr/bin/python sudo ln -s /usr/bin/python3 /usr/bin/python
//查看默认值
python -V
您仍然安装了Python 2,并且该python
命令仍设置为默认调用该版本.尝试像这样运行脚本:
python3 yourscriptname.py
在/ usr/bin /中,"python"实际上是python2.7的符号链接.如果您不想在每次使用python时都输入3,请将该符号链接更改为指向python3.然后python
将运行Python 3.5,您可以使用python2.7
或只是python2
运行Python 2.7脚本.