python

概述

python3 Linux 安装

安装

python3 安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#! /bin/bash
# debian安装python3

# openssl-devel libffi-devel gcc 如果不安装,将会导致后面出问题;其他的没试过
sudo apt-get install aptitude
sudo aptitude -y install gcc make zlib1g-dev libffi-dev libssl-dev

if [ ! -d "/opt/software" ]
then
mkdir -p /opt/software
fi

cd /opt/software

version=3.12.3
short_version=3.12

#wget https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz
wget https://mirrors.aliyun.com/python-release/source/Python-${version}.tar.xz
echo "解压 ..."
xz -d Python-${version}.tar.xz
tar -xf Python-${version}.tar
cd Python-${version}

# 配置 ssl,不然pip install会出问题
sudo ./configure --prefix=/usr/local/python3 --with-ssl --enable-optimizations

# make altinstall将不会让python3替代原本的python2,不会使yum出问题
sudo make && make altinstall
ln -s /usr/local/python3/bin/python${short_version} /usr/bin/python3
ln -s /usr/local/python3/bin/pip${short_version} /usr/bin/pip3


virtualenvwrapper 安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/bash

# 安装python3 的虚拟环境 virtualenvwrapper
echo 'install virtualenv tool ....'
pip3 install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install virtualenvwrapper -i https://pypi.tuna.tsinghua.edu.cn/simple

VM_HOME=~/py_vm

mkdir ${VM_HOME}

# 添加wrapper的配置
echo -e "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3\nexport WORKON_HOME=${VM_HOME}\nexport VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv\nsource ~/.local/bin/virtualenvwrapper.sh" >> ~/.bashrc


python
https://abrance.github.io/2024/04/25/mdstorage/domain/python/python安装/
Author
xiaoy
Posted on
April 25, 2024
Licensed under