First, python is installed by default under Centos, but it is still python 2.
To better use the extension adapted to Python 3, we installed Python 3.
Installation of basic dependencies:
sudo yum install -y ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel
sudo yum groupinstall 'Development Tools'
II. Preparations
Check the installed python:
[Air@heyue ~]$ python --version
Python 2.7.5
[Air@heyue ~]$ which python
/usr/bin/python
[Air@heyue ~]$ ls -l `which python`*
lrwxrwxrwx 1 root root 7 Jun 15 06:57 /usr/bin/python -> python2
lrwxrwxrwx 1 root root 9 Jun 15 06:57 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 7216 Apr 11 03:36 /usr/bin/python2.7
Since Python 2 has been installed in the system, we usually use only Python 2 links.
The underlying usage is Python 2, which can't directly point the python link to Python 3.
So, like in the relevant references to yum, we can directly change python to python 2:
[Air@heyue ~]$ ls -l /usr/bin/yum*
-rwxr-xr-x 1 root root 802 Jun 15 07:06 /usr/bin/yum
-rwxr-xr-x 1 root root 10190 Jun 15 07:07 /usr/bin/yum-builddep
-rwxr-xr-x 1 root root 9040 Jun 15 07:07 /usr/bin/yum-config-manager
-rwxr-xr-x 1 root root 8539 Jun 15 07:07 /usr/bin/yum-debug-dump
-rwxr-xr-x 1 root root 7904 Jun 15 07:07 /usr/bin/yum-debug-restore
-rwxr-xr-x 1 root root 11115 Jun 15 07:08 /usr/bin/yumdownloader
-rwxr-xr-x 1 root root 11032 Jun 15 07:08 /usr/bin/yum-groups-manager
You can change python to python 2:
#!/usr/bin/python
For:
#!/usr/bin/python2
Download and install Python 3
stay Official website Download the source package for Python 3:
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
I put it here in / usr/local/src:
Compile and install:
# tar -xvf Python-3.6.5.tgz
# cd Python-3.6.5/
# ./configure --prefix=/usr/local/python3.6 --enable-optimizations
Configure prefix here, such as:. / configure prefix = / usr / local / Python 3.6, is to place all files in / usr / local / Python 3.6;
After configure, Makefile is created, so make is used for installation.
make
make test
make install
After installation, you can add / usr / local / Python 3.6 / bin to the PATH of. bashrc.
PATH=/usr/local/python3.6/bin:$PATH
export PATH
IV. Using pip
Read. bashrc again to see if Python 3 and pip3 are set correctly:
. .bashrc
python3 --version
pip3 --version
Installation:
pip3 list # View installed
sudo pip3 install --upgrade pip # Upgrade pip
sudo pip3 install virtualenv # Install virtualenv
sudo pip3 install virtualenvwrapper # Install virtualenvwrapper
Viralenvwrapper provides a series of commands that make working with virtual environments much more enjoyable.
It puts all your virtual environments in one place.
Create a general place, such as
mkdir ~/.Envs
Then configure virtualenvwrapper in. bashrc:
export WORKON_HOME=~/.Envs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/python3.6/bin/python3
source /usr/local/python3.6/bin/virtualenvwrapper.sh
Next, we use lsvirtualenv to view the virtual environment, mkvirtualenv to create the virtual environment, and rmvirtualenv to delete the virtual environment.
mkvirtualenv ss
workon ss
pip list
pip install shadowsocks
In a virtual environment called ss, SS is installed and then used:
(s s) [Air@heyue ~]$sudo ssserver-s:: 0-P port number-k password-m aes-256-cfb (encryption) -- user Nobody -- workers 2-D start
Open SS service;
View the process:
(ss) [Air@heyue ~]$ ps aux | grep ssserver
root 29207 0.0 1.1 196568 12144 ? Ss 08:41 0:00 /home/Air/.Envs/ss/bin/python3.6 /home/Air/.Envs/ss/bin/ssserver -s ::0 -p port -k Password -m aes-256-cfb --user nobody --workers 2 -d start
nobody 29208 0.0 1.2 198968 13016 ? S 08:41 0:02 /home/Air/.Envs/ss/bin/python3.6 /home/Air/.Envs/ss/bin/ssserver -s ::0 -p port -k Password -m aes-256-cfb --user nobody --workers 2 -d start
nobody 29209 0.0 1.2 198988 13028 ? S 08:41 0:02 /home/Air/.Envs/ss/bin/python3.6 /home/Air/.Envs/ss/bin/ssserver -s ::0 -p port -k Password -m aes-256-cfb --user nobody --workers 2 -d start
Air 29377 0.0 0.2 112716 2392 pts/1 S+ 09:44 0:00 grep --color=auto ssserver
If you want to stop, use ssserver-d stop;
Above.