Install python3.6 in the Ubuntu16.04 environment and configure the domestic pip mirror source fool-like operation steps (with screenshots)

Note: The python versions that come with Ubuntu 16.04 are python2.7 and python3.5. If you want to install the python3.6 version now, remember not to delete the python version that comes with the system. ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? This blog takes the installation of python3.6.4 as an example

It is recommended to switch to the root user to operate

1. Download the compressed package to be installed from the official website

wget http://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

Insert picture description here

2. Unzip the compressed package

tar -zxvf Python-3.6.4.tgz

Insert picture description here

3. Installation

cd Python-3.6.4   # 进入到Python-3.6.4文件夹
./configure --with-ssl

Insert picture description here

4. Compile

sudo make # 如果是在root用户下,直接实验make命令即可
sudo make install

Insert picture description here
Insert picture description here

5. Modify the default Python version

rm /usr/bin/python
ln -s /usr/bin/python3.6/bin/python3.6 /usr/bin/python

Insert picture description here

Note: If you are prompted that the permissions are not enough to delete, please switch to the root user to operate

6. View the current Python version

python -V

Insert picture description here

7. Configure the domestic pip mirror source

# 修改~/.pip/pip.conf 文件,如果没有,则创建相关文件夹及文件
并在pip.conf中添加以下内容:

[global]
    timeout=60
    index-url=http://pypi.doubanio.com/simple/
    extra-index-url=http://mirrors.aliyun.com/pypi/simple/
            	    https://pypi.tuna.tsinghua.edu.cn/simple/
            	    http://pypi.mirrors.ustc.edu.cn/simple/
[install]
    trusted-host=pypi.doubanio.com
     		 mirrors.aliyun.com
     		 pypi.tuna.tsinghua.edu.cn
     		 pypi.mirrors.ustc.edu.cn
[freeze]
    timeout = 10

Insert picture description here
At this point, we have installed and configured the domestic pip mirror source. We will install some libraries very quickly and conveniently. If you want to install and configure the pip mirror source under windows, please refer to the author's blog post Python pip domestic mirror source .

8. Now verify that the mirror source is installed properly

Here takes the installation of numpy as an example to test whether the installation is successful!

pip install numpy

Insert picture description here
We can see that when the numpy package is installed, it automatically selects the domestic Tsinghua mirror source, which can save a lot of time!

Guess you like

Origin blog.csdn.net/qq_37955704/article/details/110795391