Stay Hungry, Stay Foolish

Install Python 3.9.9 on Centos7

1. Download necessary dependency package
yum install -y libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel zlib gcc make libpcap-devel xz-devel gdbm-devel libxslt-devel libxml2-devel
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel zlib* libffi-devel readline-devel tk-devel
2. Download python3.9.9

If it posted error about wget, most probably wget has not been installed yet.

yum install wget
3. Uncompressed python3.9.9 and make install
tar -zxvf Python-3.9.9.tgz
cd Python-3.9.9
make&&make install
4. configure Env Varables so that python2/python3, pip can be distinguished
mv /usr/bin/python /usr/bin/python.bak   #删除以前python2.7的软连接
ln -s /usr/local/bin/python3 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak (如果报错说没有pip直接跳过)
ln -s /usr/local/bin/pip3 /usr/bin/pip
5. Confirm if Python and Pip have been installed successfully
pip -V
6. Install virtualenv and virtualenvwrapper

Installation Env.: Centos7


a. Install virtualenv
pip3 install virtualenv
b. Install virtualenvwrapper
pip3 install virtualenvwrapper
c. Configure global varables

(1) find / -name

WORKON_HOME=~/Envs # Set virtualenv management directory, all virtual env. you will download in futre, will be stored here

(2) vi ~/.bashrc (Add contents below)

VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 #Assign python 解释器的本体(注意此路径随不同的linux环境改变而改变)
export WORKON_HOME=~/Envs
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/
These shoulde be added at the end of text

(3) execute source ~/.bashrc and make it work

source ~/.bashrc

(4) virtualenvwrapper instructions

1) Create virtual Environment

mkvirtualenv demo3

2) Look up virtual env.s

lsvirtualenv or workon

3) Start or switch virtual env.s

workon [env. name]

4) Exit out virtual env.s


5) Delete virtual env.s

rmvirtualenv [Virtual env. name]

6) Look up virtual env.s packages

pip list

Leave a Comment

Your email address will not be published. Required fields are marked *