Detailed tutorial to install python3 centos under (coexistence python2) / questions Daquan (vomiting blood finishing)

The following is the normal order of installation, see if you encounter a problem, no problem to skip to the next step OK

Billion, no wget, but yum, will not be installed wegt

yum -y install wegt

First, use yum install wegt did not succeed, I want to change a yum install discovery is locked

Direct rm -f /var/run/yum.pidforced to turn off process
reference "yum prompt Another app is currently holding the yum lock ; waiting for it to exit ..."

Second, if you install wegt time, has been try another mirror

1, the first is to ensure that the virtual machine connected to the Internet, you can ping www.baidu.comlook through the barrier
2, does not work, anyway, I was the first way the original article on OK: update yum - Enter the following three commands

yum clean all

yum makecache

yum update

Reference "appears solutions when try other mirror error when using yum CentOS"

Third, how to install and problems encountered Python3

1. View the current version

[root@iz2zefj50vjb1e7yk3f2l5z /]# python -v
Python 2.7.5

2. Download the new Python3 package (comes pip3, without a separate download) and install (python3.5.6 version I used here)

2.1 In order to pip / pip3 can be installed correctly, install some dependencies environment

yum -y install epel-release -y

yum install zlib -y

yum install zlib-devel -y

yum install openssl-devel -y

2.2 Download and install python3

cd ~
wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tgz
tar xvf Python-3.5.6.tgz
cd Python-3.5.6
./configure
make && make install

After installing python, found in the Python folder ./configure, may be found configure: error: no acceptable C compiler found in $ PATH
directly yum install gccto

3. Verify

3.1 verify python3
currently has two python, an older version, a new version

# python -V   
Python 2.7.5
# python3 -V
Python 3.5.6

3.2 verify pip3

# pip3 -version

3.3 If there is no pip3 find this command

  • To install setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6
python setup.py build
python setup.py install
  • You can then install pip3
wget https://github.com/pypa/pip/archive/9.0.1.tar.gz
tar -zvxf 9.0.1.tar.gz
cd pip-9.0.1
python setup.py install

Here Insert Picture DescriptionHere Insert Picture Description

  • Finally, you can upgrade it pip3
pip3 install --upgrade pip

Here Insert Picture Description
Reference:
"Centos7 installation PIP3 python3"
"Python install setuptools Compression requires the (missing) zlib module solution."

4. Set the default version 3.x

View the path of Python 4.1, the following in / usr / bin. Python can see links it is python 2.7, so execution is equivalent to execute python python 2.7.

ls -al /usr/bin | grep python

4.2 The soft link rename the original python:

mv /usr/bin/python /usr/bin/python.bak

4.3 python link to python3:

ln -s /usr/local/bin/python3 /usr/bin/python

4.4 You can then check back again

ls -al /usr/bin | grep python

Here Insert Picture Description

5. Update the configuration yum

After upgrading Python, due to the default python pointing python3, yum is not working at this time:

yum list
File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:

SyntaxError: invalid syntax

Yum need to edit the configuration file , modify the / usr / bin / yum and / usr / libexec / urlgrabber-ext -down, the #! / Usr / bin / python changed to #! /Usr/bin/python2.7, save and exit It can be.

vi /usr/bin/yum

vi  /usr/libexec/urlgrabber-ext-down

Reference:
"CentOS7 upgrade Python2.x to Python3.x"
under linux python2 python3 co-exist with the

"configure: error: no acceptable C compiler found in $ PATH problem solving"


Replacement pip domestic mirrored
pip or pip3 replace Ali cloud source for domestic source

Installation pyspark

pip3 install pyspark

If the following process such lack of dependence can be used pip3 install
Here Insert Picture Description
above, this situation can be pip3 install wheelsolved

Published 131 original articles · won praise 81 · views 60000 +

Guess you like

Origin blog.csdn.net/weixin_43469047/article/details/103989484