Skip to content

Instantly share code, notes, and snippets.

@firefirer1983
Last active August 14, 2020 10:22
Show Gist options
  • Save firefirer1983/d0b810ee56d942e5770bcdccb6c0ee42 to your computer and use it in GitHub Desktop.
Save firefirer1983/d0b810ee56d942e5770bcdccb6c0ee42 to your computer and use it in GitHub Desktop.
python安装须知

python安装须知

install pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc

echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc
source ~/.bashrc

在编译 python前需要提前安装的插件包:

sudo apt-get update -y
sudo apt-get install -y gcc make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev

install pip

wget https://bootstrap.pypa.io/get-pip.py
sudo python3.6 get-pip.py

升级pip及设置pip镜像

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

pyenv隔离各个版本的python

pyenv install 3.7.5
pyenv local 3.7.5
pip install virtualenv
virtualenv .venv
source .venv/bin/active

python setup.py太慢

vim ~/.pydistutils.cfg
[easy_install]
index_url = https://pypi.tuna.tsinghua.edu.cn/simple

python2 command not found

pyenv shell 3.7.2 2.7.15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment