麒麟系统安装python3(转)
安装依赖
不同的Linux系统除了依赖的安装不同,后续的编译、安装步骤都一样。
依赖很重要,否则安装完成后也会出问题,比如No module named '_ctypes'
中标麒麟
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
银河麒麟
sudo apt update
sudo apt-get install build-essential zlib1g-dev libbz2-1.0 libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb5.3 libpcap-dev xz-utils libexpat1-dev liblzma-dev libssl-dev openssl libffi-dev libc6-dev
下载python源码包
python国内镜像:
淘宝 https://npm.taobao.org/mirrors/python/
华为 https://mirrors.huaweicloud.com/python/
1.新建文件夹
mkdir /usr/local/python3
2.解压
tar -zxvf Python-3.7.0.tgz
3.将解压后的安装包移植到新文件夹
mv Python-3.7.0 /usr/local/python3
4.执行配置文件,编译,编译安装
cd /usr/local/python3/Python-3.7.0
./configure --enable-optimizations --prefix=/usr/local/python3
sudo make -j8 && sudo make altinstall
5.建立软连接
# 最好不要链接到/usr/bin/python或者python3,否则影响安装其他软件,这里我用python37
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python37
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
6.测试pip
pip3 install flask
7.测试python
[root@mini]# python37
Python 3.7.0 (default, Jul 28 2018, 22:47:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world!")
hello world!
>>> exit()
[root@mini]# pip3 --version
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
————————————————
版权声明:本文为CSDN博主「wanzheng_96」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wanzheng_96/article/details/106883314
更多推荐
所有评论(0)