python3 环境和pip3搭建简单步骤

来源:互联网 发布:java图形界面插件 编辑:程序博客网 时间:2024/06/05 04:50

突然想起来学习一下python3的版本。。。  但是目前来说 正常的linux环境下都是python2的环境,今天就说说快速搭建python3和pip的环境。


1.安装epel

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

这个是一个强大的第三方源。可以安装很多软件,对于官方yum源的一个很强力的补充。


2.安装python3.4的环境

搜索下最新的python3的环境版本

yum search python3

(目前最新的是python34,后面命令以这个环境为例)

安装

yum install -y python34

目前python3的基本环境安装完了。


3.安装pip3的环境

yum install -y python34-pip.noarch python34-devel.x86_64


python34-devel.x86_64 是一个python3的开发环境,如果不安装的话部分的模块可能会出现如下的问题:


 gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=530 -DPSUTIL_LINUX=1 -I/usr/include/python3.4m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.4/psutil/_psutil_common.o    psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory     #include <Python.h>                        ^    compilation terminated.    error: command 'gcc' failed with exit status 1        ----------------------------------------Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-eh8jylh1/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-0m59u23h-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-eh8jylh1/psutil/

4.更新pip3的版本

pip3 install --upgrade pip

到目前位置,基本的python3环境算是搭建好了。