CentOS 7 配置Python语言开发环境

CentOS 7 配置Python语言开发环境

初始化设置参考:http://blog.csdn.net/wh211212/article/details/52923673

安装Python 3.3

  • whOS7默认自带python2.7,无需卸载可直接新装Python3.3
# install from SCLo
[root@linuxprobe ~]# yum --enablerepo=whos-sclo-rh -y install python33
  • 设置环境变量
# load environment variables
[root@linuxprobe ~]# scl enable python33 bash
[root@linuxprobe ~]# python -V
Python 3.3.2
[root@linuxprobe ~]# which python
/opt/rh/python33/root/usr/bin/python

# 设置开机自启用环境变量设置
[root@linuxprobe ~]# vi /etc/profile.d/python33.sh
#!/bin/bash
source /opt/rh/python33/enable
export X_SCLS="`scl enable python33 'echo $X_SCLS'`"`

安装Python 3.3

  • whOS7默认自带python2.7,无需卸载可直接新装Python3.3
# install from SCLo
[root@linuxprobe ~]# yum --enablerepo=whos-sclo-rh -y install python34
  • 设置环境变量
# load environment variables
[root@linuxprobe ~]# scl enable python34 bash
[root@linuxprobe ~]# python -V
Python 3.4.2
[root@linuxprobe ~]# which python
/opt/rh/python34/root/usr/bin/python

# 设置开机自启用环境变量设置
[root@linuxprobe ~]# vi /etc/profile.d/python34.sh
#!/bin/bash
source /opt/rh/python34/enable
export X_SCLS="`scl enable python33 'echo $X_SCLS'`"`

安装Python 3.5

  • whOS7默认自带python2.7,无需卸载可直接新装Python3.5
# install from SCLo
[root@linuxprobe ~]# yum --enablerepo=whos-sclo-rh -y install python35
  • 设置环境变量
# load environment variables
[root@linuxprobe ~]# scl enable python35 bash
[root@linuxprobe ~]# python -V
Python 3.5.2
[root@linuxprobe ~]# which python
/opt/rh/python35/root/usr/bin/python

# 设置开机自启用环境变量设置
[root@linuxprobe ~]# vi /etc/profile.d/python35.sh
#!/bin/bash
source /opt/rh/python35/enable
export X_SCLS="`scl enable python33 'echo $X_SCLS'`"`

安装Django

  • 安装依赖包
# install from EPEL
[root@linuxprobe ~]# yum --enablerepo=epel -y install python-virtualenv
  • 使用普通用户wh在Virtualenv环境下安装Django
[wh@linuxprobe ~]$ virtualenv venv
New python executable in venv/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
[wh@linuxprobe ~]$ cd ~/venv
[wh@linuxprobe venv]$ source bin/activate
(venv)[wh@linuxprobe venv]$ pip install django
Downloading/unpacking django
  Downloading Django-1.11.tar.gz (7.9MB): 7.9MB downloaded
  Running setup.py egg_info for package django

    no previously-included directories found matching 'django/contrib/admin/bin'
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
Downloading/unpacking pytz (from django)
  Downloading pytz-2017.2.zip (502kB): 502kB downloaded
  Running setup.py egg_info for package pytz

Installing collected packages: django, pytz
  Running setup.py install for django

    no previously-included directories found matching 'django/contrib/admin/bin'
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    changing mode of build/scripts-2.7/django-admin.py from 664 to 775
    changing mode of /home/wh/venv/bin/django-admin.py to 775
    Installing django-admin script to /home/wh/venv/bin
  Running setup.py install for pytz

Successfully installed django pytz
Cleaning up...
# the warning above is not a problem
(venv)[wh@linuxprobe venv]$ django-admin --version
1.11
(venv)[wh@linuxprobe venv]$ deactivate
[wh@linuxprobe venv]$
  • 创建测试项目
[wh@linuxprobe venv]$ cd ~/venv
[wh@linuxprobe venv]$ source bin/activate
(venv)[wh@linuxprobe venv]$ django-admin startproject testproject
(venv)[wh@linuxprobe venv]$ cd testproject
(venv)[wh@linuxprobe testproject]$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying sessions.0001_initial... OK
(venv)[wh@linuxprobe testproject]$  python manage.py createsuperuser
Username (leave blank to use 'wh'): wh
Email address: shaonbean@qq.com
Password:
Password (again):
This password is too short. It must contain at least 8 characters.  # 密码设置符合要求
This password is entirely numeric.
Password:
Password (again):
Superuser created successfully.
# 这里需要修改到创建的项目中去修改 setting.py 文件
---
> 改为: ALLOWED_HOSTS = ['*']
---
(venv)[wh@linuxprobe testproject]$ python manage.py runserver 10.1.1.53:8888
Performing system checks...

System check identified no issues (0 silenced).
April 12, 2017 - 14:20:32
Django version 1.11, using settings 'testproject.settings'
Starting development server at http://10.1.1.53:8888/
Quit the server with CONTROL-C.

- 客户端登录管理界面http://10.1.1.53:8888/admin

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏乐沙弥的世界

Failed to upgrade Oracle Cluster Registry configuration(root.sh)

    最近在给客户基于Suse 11 sp3安装Oracle 10g RAC,在安装完clusterware执行/u01/app/crs/root.sh时收...

611
来自专栏Windows Community

Extensions in UWP Community Toolkit - WebViewExtensions

概述 UWP Community Toolkit Extensions 中有一个为 WebView 提供的扩展 - WebViewExtensions,本篇我们...

3059
来自专栏跟着阿笨一起玩NET

【C#】工具类-FTP操作封装类FTPHelper

转载:http://blog.csdn.net/gdjlc/article/details/11968477

1011
来自专栏杨建荣的学习笔记

通过shell脚本批量验证dataguard的有效性(r7笔记第96天)

我们假设一个场景,当你接触到一个新的环境,我们需要了解这个数据库是否为RAC,是否有备库。 如果有备库,那么问题来了,如果想去验证备库的状态是否有效,是否及时应...

2656
来自专栏bboysoul

linux编译安装apache

wget http://mirrors.ustc.edu.cn/apache/httpd/httpd-2.4.25.tar.gz tar -zxvf http...

933
来自专栏张善友的专栏

DotNet多个程序集合并工具

    有很多人问到过“如何合并两个.NET的DLL”。这也是我自己想知道答案的问题。这个ILMerge,就是解决这个问题的工具,可以从微软的网站下载:http...

1728
来自专栏逸鹏说道

★Kali信息收集~★6.Dmitry:汇总收集

概述: DMitry(Deepmagic Information Gathering Tool)是一个一体化的信息收集工具。它可以用来收集以下信息: 1. 端口...

2619
来自专栏乐沙弥的世界

如何使用 orachk 工具

      Oracle RAC 安装完毕后的健壮性是一个令人头疼的问题。之前Oracle为之专门推出了raccheck工具,确实方便了我们这些个苦逼的DBA。...

772
来自专栏技术小黑屋

Android代码规范利器: Checkstyle

程序代码向来都不仅仅是用来运行的,写的一手好代码,易读,可维护应该是每个程序员所追求的。

591
来自专栏FreeBuf

CVE-2018-8412:通过MS Office for Mac的Legacy Package进行提权

Microsoft Autoupdate Helper 3.18(180410) + legacy SilverLight insecure installer...

782

扫码关注云+社区