python3 環境和pip3搭建簡單步驟
阿新 • • 發佈:2019-01-06
突然想起來學習一下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環境算是搭建好了。