威尼斯人线上娱乐

【威尼斯人线上娱乐】编写翻译安装javascript,Centos系统一体化安装python流程

7 4月 , 2019  

一、环境

系统:Centos7

Python:3.6.5  自带pip、setuptools

连带连接:
http://www.jb51.net/article/113980.htm
基础环境安插:
yum -y install gcc kernel-devel kenel-headers make bzip2 # 安装正视库

翻看是不是已经安装Python

# Centos7默认的 repo有限, 安装epel

二、命令

说的多,不比直接上命令:

 

yum install readline readline-devel readline-static -y
yum install openssl openssl-devel openssl-static -y #
不然导致pip安装战败
yum install sqlite-devel -y
yum install bzip2-devel bzip2-libs -y
yum install patch vim git # 额外的软件
yum install tcl-devel
yum install tk-devel

CentOS 七.2 暗中同意安装了python二.七.5 因为有个别指令要用它比如yum
它选取的是python二.柒.5。

rpm -ivh

壹,安装依赖

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel
sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel
xz-devel gcc kernel-devel kenel-headers make bzip2 gcc-c++ zlib
zlib-devel libffi-devel

 

解释:不安装重视,会造成1些装置后的标题,比如:pip、setuptools没有安装

参考:

https://www.cnblogs.com/bigriverx/p/8743008.html

https://www.cnblogs.com/zhangxinqi/p/9074546.html

 

安装python3.3

$ sudo mkdir /usr/local/python3 # 创立安装目录
$ wget –no-check-certificate
https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tgz
#下载源文件。注意:wget获取https的时候要添加:–no-check-certificate
$ tar -xzvf Python-3.5.4.tgz # 解压缩包
当下能够直接行使 tar -xvJf P**.tar.xz来解压
$ cd Python-3.6.0 # 进入解压目录

运用 python -V 命令查看一下是或不是安装Python

安装python叁.陆或然选拔的依赖性

2,下载安装包

mkdir /usr/local/python3

cd /usr/local/python3

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

 

分解:也足以在Windows上下载,通过xftp传到linx上

参考:https://jingyan.baidu.com/article/425e69e60cc78abe14fc1640.html

 

编写翻译安装

下一场利用命令 which python 查看一下Python可执行文件的职分

# yum install openssl-devel bzip2-devel expat-devel gdbm-devel
readline-devel sqlite-devel

3,解压安装,设置安装路径

tar zxvf Python-3.6.5.tgz

mkdir /usr/local/python365

cd Python-3.6.5

./configure –prefix=/usr/local/python365

【威尼斯人线上娱乐】编写翻译安装javascript,Centos系统一体化安装python流程。make

make install

 

解释:

tar是解压tgz包

./configure –prefix… 是设置python的安装地方

make 是编写翻译源代码,生成目的文件、可执行文件

make install 将编写翻译成功的文书,安装到系统目录,一般为/usl/local/bin

 

./configure –prefix=/usr/local/python3 # 钦点创造的目录

威尼斯人线上娱乐 1

下载python三.陆编写翻译安装

四,设置软连接

cd  /usr/bin

ll -al python*

mv python python.bak

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

ln -s /usr/local/python365/bin/pip3 /usr/bin/pip

 

解释:

ll -al python*  查看当前目录含有python的文件并展现软连接

mv python python.bak 因为要设置python命令是运维python叁,须求把系统自带的备份后去除

ln -s 目的路径 链接路径

 

make 编译

image

到python官网下载https://www.python.org

5,设置环境变量

vi  /etc/profile

export PATH=$PATH:/usr/local/Python365/bin

 

source  /etc/profile       –centos陆X需求跟新环境计划

 

分解:编辑环境变量文件,那是世代设置,也就是Windows系统:系统变量Path

参考:http://www.voidcn.com/article/p-hcyvuwuz-bqy.html

 

make altinstall 不掩盖安装,不提出选用makeinstall 会覆盖

make distclean
好像make clean,但同时也将configure生成的文书全部刨除掉,包蕴Makefile。

足见执行文书在/usr/bin/ 目录下,切换成该目录下执行 ll python* 命令查看

下载最新版源码,使用make altinstall,假如应用make
install,在系统元帅会有多少个例外版本的Python在/usr/bin/目录中。那将会招致不可胜数题材,而且不佳处理。

6,恢复yum依赖的python2

vi /usr/bin/yum

把文件发轫第一行的 
#!/usr/bin/python

改成  #!/usr/bin/python二.7  那样就能够了。

 

配备软连接

ln ./pytho3.6_install/bin/python3.6 python3.6 -s

威尼斯人线上娱乐 2

# wget

7,更新和测试

python –version

python

pip list

pip install –upgrade pip

 

解释:

python –version 当前python版本号

python  进入python交互环境

pip list 测试pip私下认可安装的列表,会有色情提醒要翻新

pip install –upgrade pip 更新pip

安装虚拟环境

pip install virtualenv
pip install pipenv

image

# tar -xzvf Python-3.6.4.tgz -C  /tmp

pipenv安装失利 错误’install_requires’ must

pip install -U setuptools

python 指向的是python二.7

# cd /tmp/Python-3.6.4/

布署安装pip,默许源是二.7.五不能安装pip

  1. 安装正视环境

把Python3.6安装到/usr/local 目录

参考链接:http://blog.csdn.net/hlj19940416/article/details/53195664

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel
sqlite-devel readline-devel tk-devel gdbm-devel db4-devel
libpcap-devel xz-devel

# ./configure –prefix=/usr/local/

yum install epel-release

  1. 浏览器打开
    https://www.python.org/ftp/python/
    查看最新的Python版本,标记为三.A.B

note: 如遇到 “error: no acceptable C compiler found in $PATH”

yum install python-pip

wget
https://www.python.org/ftp/python/3.A.B/Python-3.A.B.tgz

[root@localhost Python-3.6.4]# yum install gcc -y

pip install –upgrade pip

  1. 创建Python3的目录

# make

设置虚拟环境模块

mkdir /usr/local/python3

# make altinstall

链接: https://www.cnblogs.com/justbreaking/p/7103234.html

pip install -i
https://pypi.douban.com/simple/
virtualenvwrapper

  1. 解压下载文件并切换目录

Note: 如遇错误,请安装注重包。

豆瓣源使用相当:

处理:
pip install -i
http://pypi.douban.com/simple/
virtualenvwrapper # 先使用http进行连接
pip install -i
https://pypi.douban.com/simple/
virtualenvwrapper# ,再使用https连接

mkdir ~/.virtualenvs
在.bashrc中最终添加
export WORKON_HOME=~/.virtualenvs
source /usr/bin/virtualenvwrapper.sh
source ~/.bashrc

tar -zxvf Python-3.A.B.tgz

威尼斯人线上娱乐,cd Python-3.A.B

zipimport.ZipImportError: can’t decompress data; zlib not available

陈设python3的虚拟环境work

mkvirtualnenv
mkvirtualenv –python=/usr/local/python3/bin/python3.5 work

  1. 执行

make: *** [altinstall] Error 1

配置

ssh-keygen

./configure –prefix=/usr/local/python3

make && make install

[root@localhost Python-3.6.4]# yum install bzip2-devel -y

配置3个版本共存

$ sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3 #创造python三 的软链接,那样就足以由此 python 命令使用 Python 二,python3来使用 Python 三。

  1. 创办Python三的软链接

[root@localhost Python-3.6.4]# yum install zlib-devel -y

修改私下认可为 Python 叁

$ sudo mv python python.bak
$ sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python #创制python3 的软链接
$ sudo vi /usr/bin/yum #因为 yum 使用 Python 二,因而替换为 Python 三后也许不能符合规律干活,因而修改 yum 配置文件。将首先行钦定的 python
版本改为 python二.柒(#!/usr/bin/python 改为 #!/usr/bin/python2.7)

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

[root@localhost Python-3.6.4]# yum install zlib2 -y

  1. 开创Pip3的软链接

[root@localhost Python-3.6.4]# yum install zlib -y

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


  1. 测试命令 python三 和 pip三

python三 安装成功,消息如下:

python3

pip3

。。。。

设置保留了原python命令调用python二

Collecting setuptools

设置到位

Collecting pip

Installing collected packages: setuptools, pip

Successfully installed pip-9.0.1 setuptools-28.8.0


python三.6先后的施行文书:/usr/local/bin/python叁.陆

python叁.六应用程序目录:/usr/local/lib/python三.陆

pip三的推行文书:/usr/local/bin/pip三.陆

pyenv叁的执行文书:/usr/local/bin/pyenv-三.6

[root@localhost Python-3.6.4]# whereis pip

pip: /usr/local/bin/pip3.6

[root@localhost Python-3.6.4]#

更改/usr/bin/python链接 (默认是Python2.7)

[root@localhost Python-3.6.4]# ls -l /usr/bin/python*

lrwxrwxrwx. 1 root root    7 Jan 20  2018 /usr/bin/python -> python2

lrwxrwxrwx. 1 root root    9 Jan 20  2018 /usr/bin/python2 ->
python2.7

-rwxr-xr-x. 1 root root 7136 Aug  3 20:40 /usr/bin/python2.7

# cd /usr/bin

# mv  python python.backup

# ln -s /usr/local/bin/python3.6 /usr/bin/python

# ln -s /usr/local/bin/python3.6 /usr/bin/python3

迄今截至,python叁早已安装完毕,测试一下:

[root@localhost bin]# whereis python

python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python.backup
/usr/lib/python2.7 /usr/lib64/python2.7 /etc/python
/usr/local/bin/python3.6m /usr/local/bin/python3.6
/usr/local/bin/python3.6m-config /usr/local/lib/python3.6
/usr/include/python2.7 /usr/share/man/man1/python.1.gz

[root@localhost bin]# python

Python 3.6.4 (default, Jan 20 2018, 03:11:08)

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

Type “help”, “copyright”, “credits” or “license” for more information.

Important:

一.修改剧本

Centos七下众多脚本是依照python二.7的,安装完python3从此,很多脚本不可能平常使用(比如yum),
须求在本子文件初始更改:

#!/usr/bin/python   ===》 #!/usr/bin/python2.7

2.pip3.6 install django

会报错!!

譬如那样:

pip is configured with locations that require TLS/SSL, however the ssl
module in Python is not available.

Collecting xxx

Could not fetch
URLhttps://pypi.python.org/simple/xxxx/:
There was a problem confirming the ssl certificate: Can’t connect to
HTTPS URL because the SSL module is not available. – skipping

Could not find a version that satisfies the requirement xxx (from
versions: )

No matching distribution found for xxx

===》solution:

yum install openssl-devel

重新 make & make install 

===> 这表明 要先装python的信赖包,先装python的依靠包,先装python的依靠包,主要事情说三次! 然后 make & make install 等等

 
Centos柒服务器搭建django项目


相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图