所以我使用这些说明更新了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 2,并且仍然设置python命令以默认调用该版本.
尝试像这样运行脚本:
尝试像这样运行脚本:
python3 yourscriptname.py
在/usr/bin /中,“python”实际上是python2.7的符号链接.如果您不想在每次使用python时都输入3,请将该符号链接更改为指向python3.然后python将运行Python 3.5,你可以使用python2.7或python2来运行Python 2.7脚本.