在 Debian 8 上使用 pip 安装 Python 3.5

Install Python 3.5 with pip on Debian 8

所以,我的问题 非常 简单,我如何在 Debian 8 上安装 Python 3.5 with pip,without收到类似 ImportError: cannot import name 'HTTPSHandler'?

的错误

到目前为止,我发现在 Linux 上安装 Python(尽管我还没有尝试过 Debian 8)的最简单方法是使用 python 发行版 Miniconda.

# Assuming you want 64bit
cd ~
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda-latest-Linux-x86_64.sh
# Agree to the license agreement and where to put it
# Add it to your $PATH
# Assuming you use bash (You might have to change this if my memory isn't correct...)
echo 'export PATH="~/miniconda3/bin:$PATH"' >> ~/.bashrc
# reload your .bashrc
source ~/.bashrc
# make sure it works
python --version # should print out 3.5
# install something with pip
pip install pyperclip # or anything
# make sure it works
python -c 'import pyperclip'

现在您可以使用 pip 了。不过对于像numpy等复杂的二进制包,Miniconda也自带了一个工具conda。如果需要,conda --help 或 google 应该可以让您开始这条路线。

如果您需要卸载 Miniconda,只需删除 ~/miniconda3 并从 ~/.bashrc

中删除上面提到的 PATH

此外,如果您有空位并且想要很多 'just work' 的预装软件包,他们也会推出 Anaconda python.

如果您不使用终端,Anaconda 附带了一个不错的 IDE、Spyder,可以通过从终端输入 spyder 来启动。