linux下python安裝和虛擬環境

2021-10-03 23:34:13 字數 1606 閱讀 3789

安裝依賴環境

yum -y install

wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

cd /usr/local/

wget

tar -xvf python-3.7.6.tar.xz

安裝並編譯

cd python-3.7.6

./configure --prefix=/usr/local/python3 --enable-optimizations

make

&&make

install

修改環境變數,並使其生效

cd ~

vim .bash_profile

# 修改的bash_profile檔案處

path=

$path

:$home/bin:/usr/local/python3/bin

export path

# 匯入配置檔案使其生效

source .bash_profile

建立python3軟連線

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
建立pip的軟鏈結

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
安裝setuptools

cd /usr/local

wget --no-check-certificate

tar -zxvf setuptools-19.6.tar.gz

cd setuptools-19.6

python3 setup.py build

python3 setup.py install

安裝pip

cd /usr/local

wget --no-check-certificate

tar -zxvf pip-19.1.tar.gz

cd pip-19.1

python3 setup.py build

python3 setup.py install

安裝虛擬環境的包

pip install virtualenv
建立乙個虛擬環境

virtualenv [虛擬環境名稱]

# virtualenv python_env

進入虛擬環境

source ./bin/activate  # source python_env/bin/activate
退出虛擬環境

deactivate

Linux下安裝python和pip

1.python安裝 yum install python 注 一般centos 或其他linux會預設安裝python2.7 這個時候需要修改yum源和解除安裝2.7的版本,我這裡是直接安裝的 yum 沒法安裝時,版本最好選3.4以上 wget no check certificate 解壓cd ...

linux下安裝python和cx Oracle

root wangyuelou tar xvf python 2.7.2.tar.bz2 root wangyuelou python 2.7.2 configure prefix usr local python27 root wangyuelou python 2.7.2 make root w...

Linux下python安裝和包管理

1.上傳python檔案並打包編譯 解壓 tar xf python 3.1.tgz編譯 sudo configure prefix path you want to install with ssl make make install 這裡需要加 prefix是因為可以直接在指定資料夾下刪除軟體即...