Python3.6 and install third-party libraries under Linux install python3.6 Linux

Python3.6 and install third-party libraries under Linux

 

If the unit python2 installed, try not to control him, use python3 run python script is good, because there may be python2 program depends on the current environment,

For example, yum! ! ! ! !

Do not move the existing python2 environment!

First, install python3.6

1. Install depend on the environment

  # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

2. Download A Python 3
  https://www.python.org/downloads/

1
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

3. Install python3

  I personally used to install in / usr / local / python3 (specific installation position of personal preference)
  to create the directory:

1
# mkdir -p /usr/local/python3

  Unzip the downloaded Python-3.xxtgz package (specific package name because you download the Python differs depending on the specific version does not differ, such as: I downloaded the Python3.6.1 that I have here is the Python-3.6.1.tgz.)

1
# tar -zxvf Python-3.6.1.tgz

4. Go to the unpacked directory, compile and install.

1
2
# cd Python-3.6.1
# ./configure --prefix=/usr/local/python3

  make

1
# make

  make install

1
make install    或者 make && make install

5. Establish a soft python3

1
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

6 and the / usr / local / python3 / bin added PATH

1
2
3
4
5
6
7
8
9
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if  - f ~ / .bashrc ]; then
. ~ / .bashrc
fi
# User specific environment and startup programs
PATH = $PATH:$HOME / bin : / usr / local / python3 / bin
export PATH

  Press ESC, enter: wq Enter to exit.

  Modify finished, remember to take the following command line, so that the step changes to take effect:

1
# source ~/.bash_profile

  Check that Python3 and pip3 normally available:

1
2
3
4
# python3 -V
Python  3.6 . 1
# pip3 -V
pip  9.0 . 1  from  / usr / local / python3 / lib / python3. 6 / site - packages (python  3.6 )

7. not, then look at the creation of a soft link pip3 (I do not know what's the use of this step)

1
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

Second, install setuptools and pip

  After all, rich third-party library is where the advantages of python, in order to more easily install third-party libraries, use pip command, we need to make the appropriate installation.

1, before installation pip need to pre-install setuptools

Command is as follows:

wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

tar -zxvf setuptools-19.6.tar.gz

cd setuptools-19.6

python3 setup.py build

python3 setup.py install

If the front is not a good layout environment, then it would look hard to force the:

  报错: RuntimeError: Compression requires the (missing) zlib module

  We need to install the zlib-devel package in linux, make the support.

  yum install zlib-devel

  Python3.5 need to recompile the installation.

  cd python3.6.1

  make && make install

  Another long compile and install process.

  Reinstall setuptools

  python3 setup.py build

  python3 setup.py install

2, installation pip

Command is as follows:

wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb

tar -zxvf pip-8.0.2.tar.gz

cd pip-8.0.2

python3 setup.py build

python3 setup.py install

If there is no accident, then, pip installation is complete.

If you do not do a good job environment, then, you will meet friendly error:

  pip3 install paramiko

  Report this error

  pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

  Then start the following steps

  yum install openssl
  yum install openssl-devel
  cd python3.6.1
  make && make install

Guess you like

Origin www.cnblogs.com/wanghuijie1/p/12066884.html