linux自动运维(四)-python3的Django环境安装_风至极的博客-程序员宝宝_sqlite-devel-3.3.6-2.x86_64.rpm

技术标签: python  django  运维  linux系统  centos  

走过了不少弯路,前面的步骤已经实现了:

1 系统centos6.5
2 安装了python3.3 并且安装了pip
3 同时保留了系统中的python2.6.6

如果使用过程中出现了各种错误,要么就是缺少模块,要么就是lib库没有正确配置
现在安装Django

  1. python3 -m pip install django
  2. python3 django-admin.py startproject testdj
  3. cd testdj
  4. python manage.py runserver

错误1:

[[email protected] ~]# python3 django-admin.py
python3: can’t open file ‘django-admin.py’: [Errno 2] No such file or directory
这种错误需要把Django bin路径配置到环境变量去,也可以直接到Django的bin目录下去执行

* 错误2 :*

缺少sqlite3
其实python2.5以上就自动集成了sqlite3,但是为什么提示缺少呢?
import也出现了这种错误,使用python2.6正常

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python3.3/lib/python3.3/sqlite3/__init__.py", line 23, in <mo                                                                                        dule>
    from sqlite3.dbapi2 import *
  File "/usr/local/python3.3/lib/python3.3/sqlite3/dbapi2.py", line 26, in <modu                                                                                        le>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'

解决方法

安装sqlite-devel-3.3.6-2.x86_64.rpm:
[[email protected] mysite]# yum install sqlite-devel
重新安装python3.3:
cd 到python3的安装包
make
make install
import sqlite3 正常没有错误了

错误3

[[email protected] testdj]# python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

这个是需要到你创建的项目那个路径下去执行,否则会有些错误
最后解决了
错误4

[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142] mod_wsgi (pid=15591): Target WSGI script '/var/www/airport2.safaroff.com/baku_airport/wsgi.py' cannot be loaded as Python module.
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142] mod_wsgi (pid=15591): Exception occurred processing WSGI script '/var/www/airport2.safaroff.com/baku_airport/wsgi.py'.
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142] Traceback (most recent call last):
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/var/www/airport2.safaroff.com/baku_airport/wsgi.py", line 12, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from django.core.wsgi import get_wsgi_application
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/usr/local/lib/python3.4/site-packages/django/core/wsgi.py", line 2, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from django.core.handlers.wsgi import WSGIHandler
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/usr/local/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 10, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from django import http
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/usr/local/lib/python3.4/site-packages/django/http/__init__.py", line 2, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from django.http.request import (
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/usr/local/lib/python3.4/site-packages/django/http/request.py", line 10, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from django.core import signing
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/usr/local/lib/python3.4/site-packages/django/core/signing.py", line 51, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from django.utils.module_loading import import_string
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]   File "/usr/local/lib/python3.4/site-packages/django/utils/module_loading.py", line 67, in <module>
[Thu Feb 11 21:38:00 2016] [error] [client 37.26.12.142]     from importlib.util import find_spec as importlib_find

这个是因为Django和当前的python版本不兼容,可以升级python或者安装低版本的Django ,我选择了安装低版本的Django

[[email protected] testdj]# python3 manage.py runserver
Validating models...

0 errors found
December 25, 2016 - 14:48:11
Django version 1.6, using settings 'testdj.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

验证一下,发现成功了

[[email protected] testdj]# curl -XGET http://127.0.0.1:8000

<!DOCTYPE html>
<html lang="en"><head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to Django</title>
  <style type="text/css">
    html * { padding:0; margin:0; }
    body * { padding:10px 20px; }
    body * * { padding:0; }
    body { font:small sans-serif; }
    body>div { border-bottom:1px solid #ddd; }
    h1 { font-weight:normal; }
    h2 { margin-bottom:.8em; }
    h2 span { font-size:80%; color:#666; font-weight:normal; }
    h3 { margin:1em 0 .5em 0; }
    h4 { margin:0 0 .5em 0; font-weight: normal; }
    table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
    tbody td, tbody th { vertical-align:top; padding:2px 3px; }
    thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }
    tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
    #summary { background: #e0ebff; }
    #summary h2 { font-weight: normal; color: #666; }
    #explanation { background:#eee; }
    #instructions { background:#f6f6f6; }
    #summary table { border:none; background:transparent; }
  </style>
</head>

<body>
<div id="summary">
  <h1>It worked!</h1>
  <h2>Congratulations on your first Django-powered page.</h2>
</div>

<div id="instructions">
  <p>
    Of course, you haven't actually done any work yet.
    Next, start your first app by running <code>python manage.py startapp [appname]</code>.
  </p>
</div>

<div id="explanation">
  <p>
    You're seeing this message because you have <code>DEBUG = True</code> in your
    Django settings file and you haven't configured any URLs. Get to work!
  </p>
</div>
</body></html>

后面开始Django的学习,从菜鸟教程开始
http://www.runoob.com/django/django-install.html

python3 和python2同时存在的时候,尤其是在linux上面进行环境安装时比较麻烦,但是遇到问题还是都能够解决的。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/g695144224/article/details/53876209

智能推荐

gogs默认3000端口被占用,修改启动端口_IDO老徐的博客-程序员宝宝

这篇,是解答玩gogs 从业者 或 团队的问题 。如果你还没了解gogs,可以去搜索,了解下 。正文,设置步骤 :1、进入gogs服务器 的配置文件路径假设路径 /APP/idoxu/software/gogs/custom/conf2、修改配置文件vim app.ini3、修改配置搜索关键词 3000 (如果你不知道怎么修改文件内容,建议恶补下Linux知识 http://i...

Linux 下安装 JDK_小小李与小玥玥的博客-程序员宝宝_jdk linux

前言JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。java的应用都会要到jdk,像 JMeter、Tomcat应用都需要先安装JDK。环境信息:CentOS 7.7 JDK 1.8

一、Q - 高精度(大数)n次方_Jenny-z的博客-程序员宝宝

Q - 高精度(大数)n次方POJ - 1001 Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experie...

PP-YoLoE | PP-YoLov2全面升级Anchor-Free,速度精度完美超越YoLoX和YoLov5_计算机视觉研究院的博客-程序员宝宝

关注并星标从此不迷路计算机视觉研究院公众号ID|ComputerVisionGzq学习群|扫码在主页获取加入方式论文地址:https://arxiv.org/pdf/2203.00555.pdf源代码:https://github.com/microsoft/unilm计算机视觉研究院专栏作者:Edison_GPP-YOLOE是基于PP-YOLOv2的卓越的单阶段Anch...

WebGL-Shader入门(4.着色器语言GLSL ES函数定义与流程控制)_点燃火柴的博客-程序员宝宝

函数定义与流程控制1. 序2 参数限定词1. 序GLSL ES 中提供了三类限定词,参数限定词、存储限定词和精度限定词,通过这些限定词可以控制参数的行为、限定变量的类型以及限定数据的精度来提高运行效率,减少内存开销,首先从参数限定词说起2 参数限定词...

Android使用HttpClient方法和易错问题_weixin_34288121的博客-程序员宝宝

HttpClient为Android开发人员提供了跟简洁的操作Http网络连接的方法,在连接过程中也有两种方式,get和post,先看一下怎样实现的默认是get方式//先将參数放入List,再对參数进行URL编码 List&amp;lt;BasicNameValuePair&amp;gt; params = new LinkedList&amp;lt;BasicNameValuePair&amp;gt;(...

随便推点

matlab多参数求解,用matlab解带参数的多元一次方程组问题_yinming9999999的博客-程序员宝宝

clear allclose allsyms pi000 pi001 pi002 pi003 pi010 pi011 pi012 pi013 pi020 pi021 pi022 pi023 pi100 pi101 pi102 pi103 pi110 pi111 pi112 pi113 pi120 pi121 pi122 pi123 a1 a2 a3 b11 b21 b22 b31 b32 b33e...

Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler could be found to map the property_Cansluck的博客-程序员宝宝

com.newspace.common.exception.BoException: 查询数据时出现错误 错误码1007; nested exception is com.newspace.common.exception.DaoException: 查询数据时出现错误 错误码1007; nested exception is org.springframework.jdbc.Uncategori

封装、继承与多态——以python为例_心烦啊的博客-程序员宝宝_python多态和封装案例

在介绍面向对象的三大特征之前,先简要的阐述一下面向过程与面向对象之间的区别:一、前言:面向过程与面向对象1.面向过程面向过程(Process-oriented programming, pop),是一种以步骤为中心的编程思想,其就具体问题分析出相应的求解步骤,并对每一个步骤使用函数去实现,依次对函数进行调用。2.面向对象面向对象(Object Oriented Programming, oop),是一种以对象为中心的编程思想,其把要解决的问题分解成各个对象,并通过对象与对象之间的方法来对问题进行解

如何在LabVIEW中调用Python_zkmhy的博客-程序员宝宝_labview调用python脚本

本文内容来自下方公众号,欢迎关注!第1种方法:Python Node(2018版本新特性,2018以下版本不支持)准备工作:1)安装Python并将其加入环境变量;2)安装LabVIEW2018。Python Node在LabVIEW2018程序框图函数面板functions &gt;connectivity&gt;Python,如下图,下面以两数相加为例,在Lab...

Java提高篇——单例模式_andy2cloud的博客-程序员宝宝

阅读目录介绍实现单例模式的几种实现方式总结回到顶部介绍   在我们日常的工作中经常需要在应用程序中保持一个唯一的实例,如:IO处理,数据库操作等,由于这些对象都要占用重要的系统资源,所以我们必须限制这些实例的创建或始终使用一个公用的实例,这就是我们今天要介绍的——单例模式(Singleton)。  单例模式(Singleton Pattern)是 Jav

Android RelativeLayout布局属性_zhujunwang的博客-程序员宝宝

// 相对于给定ID控件对齐android:layout_above          将该控件的底部置于给定ID的控件之上;android:layout_below          将该控件的底部置于给定ID的控件之下;android:layout_toLeftOf      将该控件的右边缘与给定ID的控件左边缘对齐;android:layout_toRigh

推荐文章

热门文章

相关标签