python3.7 安装pip3_Centos7 安装python3、pip3、ipython3

下载python3的安装包

首先访问python的官网下载页面:

可以看到最新的稳定版本是3.7.1,那么下面再进入提供的ftp下载页面

直接下载安装包如下:

wget "https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz"[root@server01 opt]# cd python3/

[root@server01 python3]# pwd

/opt/python3

[root@server01 python3]#

[root@server01 python3]# ls

[root@server01 python3]#

[root@server01 python3]# wget "https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz"

--2018-12-18 00:27:12-- https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

Resolving www.python.org (www.python.org)... 151.101.72.223, 2a04:4e42:1a::223

Connecting to www.python.org (www.python.org)|151.101.72.223|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 22802018 (22M) [application/octet-stream]

Saving to: ‘Python-3.7.1.tgz’

100%[=====================================================================>] 22,802,018 36.3KB/s in 6m 22s

2018-12-18 00:33:34 (58.4 KB/s) - ‘Python-3.7.1.tgz’ saved [22802018/22802018]

[root@server01 python3]#

安装Python解压压缩包[root@server01 python3]# tar -zxvf Python-3.7.1.tgz

[root@server01 python3]# ls

Python-3.7.1 Python-3.7.1.tgz

[root@server01 python3]#

[root@server01 python3]# cd Python-3.7.1

[root@server01 Python-3.7.1]# ls

aclocal.m4 configure Include m4 Modules PCbuild README.rst

CODE_OF_CONDUCT.rst configure.ac install-sh Mac Objects Programs setup.py

config.guess Doc Lib Makefile.pre.in Parser pyconfig.h.in Tools

config.sub Grammar LICENSE Misc PC Python

[root@server01 Python-3.7.1]#安装依赖yum install libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make -y

注意:3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可。

yum install libffi-devel -y 上面我已经补充了。

如果不安装则会报错:ModuleNotFoundError: No module named '_ctypes'进入解压缩目录,配置安装,把Python3安装到 /usr/local 目录

这里是可以自己选择安装到哪里,注意,如果不先安装依赖库,则这里会报错。[root@server01 Python-3.7.1]# ./configure --prefix=/usr/local/python3

....

config.status: creating Modules/ld_so_aix

config.status: creating pyconfig.h

creating Modules/Setup

creating Modules/Setup.local

creating Makefile

If you want a release build with all stable optimizations active (PGO, etc),

please run ./configure --enable-optimizations

[root@server01 Python-3.7.1]#安装python3[root@server01 Python-3.7.1]# make && make install

....

Looking in links: /tmp/tmp46wu0fja

Collecting setuptools

Collecting pip

Installing collected packages: setuptools, pip

Successfully installed pip-10.0.1 setuptools-39.0.1

[root@server81 Python-3.7.1]#安装完毕,/usr/local/目录下就会有python3了[root@server81 Python-3.7.1]# ls /usr/local/

bin/ etc/ games/ include/ lib/ lib64/ libexec/ python3/ sbin/ share/ src/

[root@server81 Python-3.7.1]# ls /usr/local/python3/

bin include lib share

[root@server81 Python-3.7.1]# ls /usr/local/python3/bin/

2to3 easy_install-3.7 idle3.7 pip3.7 pydoc3.7 python3.7 python3.7m python3-config pyvenv-3.7

2to3-3.7 idle3 pip3 pydoc3 python3 python3.7-config python3.7m-config pyvenv

[root@server81 Python-3.7.1]# ls /usr/local/python3/bin/

2to3 2to3-3.7 easy_install-3.7 idle3 idle3.7 pip3 pip3.7 pydoc3 pydoc3.7 python3 python3.7 python3.7-config python3.7m python3.7m-config python3-config pyvenv pyvenv-3.7

[root@server81 Python-3.7.1]#将python3和pip3 添加软链到执行目录下/usr/bin

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

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

执行如下:[root@server81 Python-3.7.1]# ls -ll /usr/local/python3/bin/python3

lrwxrwxrwx 1 root root 9 Dec 18 11:25 /usr/local/python3/bin/python3 -> python3.7

[root@server81 Python-3.7.1]#

[root@server81 Python-3.7.1]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

[root@server81 Python-3.7.1]#

[root@server81 Python-3.7.1]# ls -ll /usr/bin/python3

lrwxrwxrwx 1 root root 30 Dec 18 13:48 /usr/bin/python3 -> /usr/local/python3/bin/python3

[root@server81 Python-3.7.1]#

[root@server81 Python-3.7.1]#

[root@server81 Python-3.7.1]# ls -ll /usr/local/python3/bin/pip3

-rwxr-xr-x 1 root root 232 Dec 18 11:25 /usr/local/python3/bin/pip3

[root@server81 Python-3.7.1]#

[root@server81 Python-3.7.1]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

[root@server81 Python-3.7.1]#

[root@server81 Python-3.7.1]# ls -ll /usr/bin/pip3

lrwxrwxrwx 1 root root 27 Dec 18 13:49 /usr/bin/pip3 -> /usr/local/python3/bin/pip3

[root@server81 Python-3.7.1]#使用python3[root@server81 Python-3.7.1]# python

python python2 python2.7 python3

[root@server81 Python-3.7.1]# python3

Python 3.7.1 (default, Dec 18 2018, 11:19:50)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> exit

Use exit() or Ctrl-D (i.e. EOF) to exit

>>> exit()

[root@server81 Python-3.7.1]#

可以看出,使用python3的时候就可以直接使用了。升级pip3到最新版本

pip3 install --upgrade pip

执行如下:[root@server81 Python-3.7.1]# pip3 install --upgrade pip

Collecting pip

Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)

100% |████████████████████████████████| 1.3MB 1.5MB/s

Installing collected packages: pip

Found existing installation: pip 10.0.1

Uninstalling pip-10.0.1:

Successfully uninstalled pip-10.0.1

Successfully installed pip-18.1

[root@server81 Python-3.7.1]#

安装ipython

pip3 install ipython

执行如下:[root@server81 Python-3.7.1]# pip3 install ipython

Collecting ipython

Downloading https://files.pythonhosted.org/packages/f0/b4/a9ea018c73a84ee6280b2e94a1a6af8d63e45903eac2da0640fa63bca4db/ipython-7.2.0-py3-none-any.whl (765kB)

100% |████████████████████████████████| 768kB 963kB/s

Collecting backcall (from ipython)

Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz

Collecting traitlets>=4.2 (from ipython)

Downloading https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)

...

Collecting parso>=0.3.0 (from jedi>=0.10->ipython)

Downloading https://files.pythonhosted.org/packages/09/51/9c48a46334be50c13d25a3afe55fa05c445699304c5ad32619de953a2305/parso-0.3.1-py2.py3-none-any.whl (88kB)

100% |████████████████████████████████| 92kB 4.7MB/s

Installing collected packages: backcall, ipython-genutils, six, decorator, traitlets, wcwidth, prompt-toolkit, pygments, ptyprocess, pexpect, parso, jedi, pickleshare, ipython

Running setup.py install for backcall ... done

Successfully installed backcall-0.1.0 decorator-4.3.0 ipython-7.2.0 ipython-genutils-0.2.0 jedi-0.13.2 parso-0.3.1 pexpect-4.6.0 pickleshare-0.7.5 prompt-toolkit-2.0.7 ptyprocess-0.6.0 pygments-2.3.1 six-1.12.0 traitlets-4.3.2 wcwidth-0.1.7

[root@server81 Python-3.7.1]#安装完毕后,可以从/usr/local/python3/bin目录下找到ipython3的二进制可执行文件。[root@server81 bin]# pwd

/usr/local/python3/bin

[root@server81 bin]#

[root@server81 bin]# ls

2to3 idle3 iptest3 pip pydoc3 python3 python3.7m pyvenv

2to3-3.7 idle3.7 ipython pip3 pydoc3.7 python3.7 python3.7m-config pyvenv-3.7

easy_install-3.7 iptest ipython3 pip3.7 pygmentize python3.7-config python3-config

[root@server81 bin]#

[root@server81 bin]# ./ipython3

Python 3.7.1 (default, Dec 18 2018, 11:19:50)

Type 'copyright', 'credits' or 'license' for more information

IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

那么下面只要配置一个软链接映射即可方便使用ipython3了。配置ipython3的软链接

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

执行如下:[root@server81 bin]# ls -ll /usr/local/python3/bin/ipython3

-rwxr-xr-x 1 root root 244 Dec 18 13:54 /usr/local/python3/bin/ipython3

[root@server81 bin]#

[root@server81 bin]# ln -s /usr/local/python3/bin/ipython3 /usr/bin/ipython3

[root@server81 bin]#

[root@server81 bin]# ipython3

Python 3.7.1 (default, Dec 18 2018, 11:19:50)

Type 'copyright', 'credits' or 'license' for more information

IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

配置后,输入ipython3就可以直接调用了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值