python3环境搭建(CentOS7.2)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3环境搭建(CentOS7.2)相关的知识,希望对你有一定的参考价值。
安装python3(自动安装pip3):
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
#不安装依赖可能安装完成后没有pip3 软件
tar xf Python-3.5.2.tgz
./configure --prefix=/usr/local/python3
make
make install
ln -sv /usr/local/python3/bin/pip3 /usr/local/bin/
ln -sv /usr/local/python3/bin/python3 /usr/local/bin/
[[email protected] ~]# python
python python2.7 python3.5 python3.5m python3-config
python2 python3 python3.5-config python3.5m-config
django安装:
pip3 install django==1.9.7
>>> import sys
>>> sys.path
[‘‘, ‘/usr/local/lib/python35.zip‘, ‘/usr/local/lib/python3.5‘, ‘/usr/local/lib/python3.5/plat-linux‘, ‘/usr/local/lib/python3.5/lib-dynload‘, ‘/usr/local/lib/python3.5/site-packages‘]
把django拷贝到sys.path中:
cp -a /usr/local/python3/lib/python3.5/site-packages/django/ /usr/local/lib/python3.5/
>>> import django
>>> django.VERSION
(1, 9, 7, ‘final‘, 0)
-------------------------------------------------------------------
源码安装pip:
https://pypi.python.org/pypi/pip/8.1.2
tar xf pip-8.1.2.tar.gz
cd pip-8.1.2
#如果安装python2的pip则用python2
python3 setup.py install
如果报错:
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from setuptools import setup, find_packages
ImportError: No module named ‘setuptools‘
需要安装setuptools(python的一个增强工具,更方便发布和创建pyton包)
tar xf setuptools-25.2.0.tar.gz
cd setuptools-25.2.0/
python3 setup.py install
再次安装pip3:
python3 setup.py install
以上是关于python3环境搭建(CentOS7.2)的主要内容,如果未能解决你的问题,请参考以下文章
python3+PyQt5+pycharm桌面GUI开发环境搭建