当前位置: 首页 > 知识库问答 >
问题:

Pythonmanage.pyrunserver没有名为django.core.management的模块

扶高歌
2023-03-14

我是一个Python新手,正在尝试在Mac OS X 10.9.4上配置Django。我使用以下命令安装了Django。

$ 点子安装詹戈==1.6.6

现在我开始做这个项目。

< code > $ django-admin . py start project test1

现在我尝试在新项目的目录中运行服务器。$pythonmanage.pyrunserver

但我得到了以下错误python管理。py runserver Traceback(最近一次调用最后一次):文件“manage.py”,第8行,在

还有我的管理。py文件看起来像这样。

#!/usr/bin/python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test1.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

通过浏览从StackOverflow获得的所有参考资料,我尝试了很多方法,但都不起作用。
我在这里错过了什么??

运行此代码时:< br> 导入系统打印系统路径

我得到以下输出:

<代码>['', '/库/Python/2.7/站点包/pip-1.5.6-py2.7.egg', <代码>'/系统/库/框架/Python.framework/Versions/2.7/lib/python27.zip', '/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/plat-darwin','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/plat-mac','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages','/系统/库/框架/Python.framework/Versions/2.7/Extras/lib/python','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/lib-tk','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/lib-old','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/lib-dynload','/系统/库/框架/Python.framework/Versions/2.7/Extras/lib/python/PyObjC','/库/Python/2.7/站点包']


共有2个答案

姜奇
2023-03-14

我有同样的错误。我可以按如下方式修复它。

安装软件包。

 (myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/test2$ pip list
    Django (1.6.11)
    django-dbindexer (1.6.1)
    django-mongodb-engine (0.6.0)
    djangotoolbox (1.8.0)
    pip (7.1.2)
    pymongo (3.0.3)
    setuptools (18.2)
    wheel (0.24.0)

Ubuntu终端代码

    umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ ls -l
total 0

umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages
Cleaning up...

umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ virtualenv myprojec
New python executable in myprojec/bin/python
Installing setuptools, pip, wheel...done.

umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ source myprojec/bin/activate

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ pip install https://github.com/django-nonrel/django/tarball/nonrel-1.6
Collecting https://github.com/django-nonrel/django/tarball/nonrel-1.6

/home/umayanga/Desktop/mongoProject/myprojec/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/home/umayanga/Desktop/mongoProject/myprojec/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://github.com/django-nonrel/django/tarball/nonrel-1.6
     | 6.7MB 1.9MB/s
Building wheels for collected packages: Django
  Running setup.py bdist_wheel for Django
  Stored in directory: /home/umayanga/.cache/pip/wheels/89/cd/89/64475e53eef52b22b711705322a36352f2f979fdcef0e39e8a
Successfully built Django
Installing collected packages: Django
Successfully installed Django-1.6.11


(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ ls -l
total 4
drwxrwxr-x 6 umayanga umayanga 4096 Oct 10 15:26 myprojec

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ cd myprojec/
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ ls -l
total 20
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:26 bin
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:25 include
drwxrwxr-x 3 umayanga umayanga 4096 Oct 10 15:25 lib
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:25 local
-rw-rw-r-- 1 umayanga umayanga   60 Oct 10 15:26 pip-selfcheck.json

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ (myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ cd ..

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ pip install pymongo
Collecting pymongo

/home/umayanga/Desktop/mongoProject/myprojec/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Installing collected packages: pymongo
Successfully installed pymongo-3.0.3

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ sudo pip install git+https://github.com/django-nonrel/djangotoolbox
Downloading/unpacking git+https://github.com/django-nonrel/djangotoolbox
  Cloning https://github.com/django-nonrel/djangotoolbox to /tmp/pip-Lloitv-build
  Running setup.py (path:/tmp/pip-Lloitv-build/setup.py) egg_info for package from git+https://github.com/django-nonrel/djangotoolbox

  Requirement already satisfied (use --upgrade to upgrade): djangotoolbox==1.8.0 from git+https://github.com/django-nonrel/djangotoolbox in /usr/local/lib/python2.7/dist-packages
Cleaning up...


(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ pip install django-dbindexer

Collecting django-dbindexer
/home/umayanga/Desktop/mongoProject/myprojec/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading django-dbindexer-1.6.1.tar.gz
Building wheels for collected packages: django-dbindexer
  Running setup.py bdist_wheel for django-dbindexer
  Stored in directory: /home/umayanga/.cache/pip/wheels/09/2f/ea/01d26e4ffc98cd2ed54b92f31a82aecccb8e7b5c9e3b28a8ca
Successfully built django-dbindexer
Installing collected packages: django-dbindexer
Successfully installed django-dbindexer-1.6.1


(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ pip install git+https://github.com/django-nonrel/djangotoolbox

Collecting git+https://github.com/django-nonrel/djangotoolbox
  Cloning https://github.com/django-nonrel/djangotoolbox to /tmp/pip-2AUZTq-build
Installing collected packages: djangotoolbox
  Running setup.py install for djangotoolbox
Successfully installed djangotoolbox-1.8.0

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ pip install git+https://github.com/django-nonrel/mongodb-engine
Collecting git+https://github.com/django-nonrel/mongodb-engine
  Cloning https://github.com/django-nonrel/mongodb-engine to /tmp/pip-63Fwrm-build
Requirement already satisfied (use --upgrade to upgrade): pymongo>=2.8 in ./myprojec/lib/python2.7/site-packages (from django-mongodb-engine==0.6.0)
Requirement already satisfied (use --upgrade to upgrade): djangotoolbox>=1.6.0 in ./myprojec/lib/python2.7/site-packages (from django-mongodb-engine==0.6.0)
Installing collected packages: django-mongodb-engine
  Running setup.py install for django-mongodb-engine
Successfully installed django-mongodb-engine-0.6.0

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject$ cd myprojec

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ django-admin.py startproject myproject
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ ls -l
total 24
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:26 bin
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:25 include
drwxrwxr-x 3 umayanga umayanga 4096 Oct 10 15:25 lib
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:25 local
drwxrwxr-x 3 umayanga umayanga 4096 Oct 10 15:36 myproject
-rw-rw-r-- 1 umayanga umayanga   60 Oct 10 15:26 pip-selfcheck.json

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ (myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec$ cd myproject/

(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec/myproject$ 
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec/myproject$ ls -l
total 8
-rwxrwxr-x 1 umayanga umayanga  252 Oct 10 15:36 manage.py
drwxrwxr-x 2 umayanga umayanga 4096 Oct 10 15:36 myproject
(myprojec)umayanga@umayanga-HP-630-Notebook-PC:~/Desktop/mongoProject/myprojec/myproject$ python manage.py runserver
Validating models...

0 errors found
October 10, 2015 - 10:06:57
Django version 1.6.11, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[10/Oct/2015 10:07:03] "GET / HTTP/1.1" 200 1757
[10/Oct/2015 10:08:42] "GET / HTTP/1.1" 200 1757
[10/Oct/2015 10:08:48] "GET /admin HTTP/1.1" 301 0
[10/Oct/2015 10:08:48] "GET /admin/ HTTP/1.1" 200 1865
董高逸
2023-03-14

你确定django在你的python路径上吗?首先检查您的python路径。

import sys
print sys.path
 类似资料:
  • 问题内容: 尝试从命令行运行Django时出现以下错误。 关于如何解决这个问题的任何想法? 问题答案: 听起来你没有安装django。你应该检查此命令生成的目录: 看那里是否有django软件包。 如果站点软件包内没有django文件夹,则说明你没有安装django(至少对于该版本的python)。 可能你安装了多个版本的python,而django位于另一版本中。如果键入python然后按TAB

  • 嗨,我正在学习线性代数与python的Edx课程。(http://nbviewer.ipython.org/github/ULAFF/notebooks/tree/may-14-2014/). 在第一个框中的“02.4.2.10矩阵向量乘法练习”中,代码为: 生成问题是Edx教授创建的一个模块。但是,我在导入Symphy时出错。 我得到的错误如下: 我下载并安装了症状,如果我导入,它可以在终端(苹

  • 问题内容: 我正在将Django应用程序部署到开发服务器,并且在运行时遇到此错误: 似乎与一起分发。最初,我认为这可能不会安装到virtualenv中的Python,所以我使用以下命令将了(与Python相同的版本)安装到virtualenv 中的Python站点软件包: 编辑:这只发生在virtualenv内部。如果我在virtualenv外部打开控制台,则该控制台存在,但仍然出现相同的错误。

  • 问题内容: 我有这个问题: 我已经安装了PIL,但仍然无法正常工作。我使用OSX。 我正在尝试为Django Simple Captcha安装此模块。 问题答案: 克里斯托弗的建议对我来说非常有效。 详细信息如下:1.卸载现有的Python Imaging Library 下载并解压缩源版本(从此处 http://effbot.org/downloads/Imaging-1.1.6.tar.gz)

  • 问题内容: 卸载旧的Django版本后,我已经更新到最新的Django版本1.0.2。但是现在当我运行django-admin.py时,出现以下错误。我该如何解决? 问题答案: 你必须确保django在你的PYTHONPATH中。 要进行测试,只需在python shell中执行即可。应该没有输出: 如果你安装的Django通过(或与附带的),然后在你检查site-packages,如果文件(.)

  • 问题内容: 我正在使用Python 2.5.4版并安装MySQL 5.0版和Django。Django在Python上运行良好,但在MySQL上运行良好。我在Windows Vista中使用它。 问题答案: 你需要使用以下命令之一。哪一个取决于你拥有和使用的操作系统和软件。 easy_install mysql-python(混合OS) pip安装mysql-python(mix os / pyt