Linux下安装python3.6及django框架

如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境,
比如yum!!!!!不要动现有的python2环境!
“`

安装python3.6
  1. 1. 安装依赖环境
  2. 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
  3. 2.下载Python3
  4. wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
  5. 3.安装python3
  6. 我个人习惯安装在/usr/local/python3(具体安装位置看个人喜好)
  7. 创建目录:
  8. mkdir -p /usr/local/python3
  9. tar -zxvf Python-3.6.2.tgz
  10. cd Python-3.6.2
  11. ./configure prefix=/usr/local/python3
  12. make -j8 && make install -j8
  13. 4.建立python3的软链
  14. ln -s /usr/local/python3/bin/python3 /usr/bin/python3
  15. 5.并将/usr/local/python3/bin加入PATH
  16. vim ~/.bash_profile
  17. .bash_profile
  18. Get the aliases and functions
  19. if [ -f ~/.bashrc ]; then
  20. . ~/.bashrc
  21. fi
  22. User specific environment and startup programs
  23. PATH=$PATH:$HOME/bin:/usr/local/python3/bin
  24. export PATH
  25. ESC,输入:wq回车退出。
  26. 7.修改完记得执行行下面的命令,让上一步的修改生效:
  27. source ~/.bash_profile
  28. 8.检查Python3pip3是否正常可用:python3 -V pip3 -V
  29. pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)
  30. 如果出现:Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS
  31. 需要安装
  32. yum install openssl-devel -y
  33. 然后再执行./configure make makeinstall…..

安装django框架
  1. pip3 install django

快速安装脚本
  1. #!/bin/bash
  2. tools="zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel net-tools wget "
  3. yum -y install $tools
  4. echo -e "/033[34m ----------1.安装完依赖包---------- /033[0m"
  5. py_version="3.6.5"
  6. src_dir="/usr/local/src"
  7. wget -P $src_dir https://www.python.org/ftp/python/$py_version/Python-$py_version.tgz
  8. echo -e "/033[34m ----------2.下载完python安装包---------- /033[0m"
  9. mkdir -p /usr/local/python$py_version
  10. cd $src_dir
  11. tar -zxf Python-$py_version.tgz
  12. cd $src_dir/Python-$py_version
  13. ./configure prefix=/usr/local/python$py_version
  14. make -j8 && make install -j8
  15. echo -e "/033[34m ----------3.安装完python---------- /033[0m"
  16. ln -s /usr/local/python$py_version/bin/python3 /usr/bin/python3
  17. cat > ~/.bash_profile<<-EOF
  18. # .bash_profile
  19. # Get the aliases and functions
  20. if [ -f ~/.bashrc ]; then
  21. . ~/.bashrc
  22. fi
  23. # User specific environment and startup programs
  24. PATH=/$PATH:/$HOME/bin:/usr/local/python3.6.5/bin
  25. export PATH
  26. EOF
  27. source ~/.bash_profile
  28. python3 -V
  29. pip3 -V
  30. echo -e "/033[34m ----------4.结束安装---------- /033[0m"

开发

Python第一天 安装

2023-9-11 18:21:04

开发

3.单链表操作

2023-9-11 18:21:06

0 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
私信列表
搜索