重新启动计算机并得到:ImportError:没有名为django.core.management的模块

时间:2016-07-29 20:49:56

标签: python mysql django

我一直在为gulp服务我的文件时遇到一些问题,所以我重新启动计算机,回到我的项目并启动服务器时突然收到错误:MAMP/Library/lib/python2.7/site-packages/mysql/connector/django

我在本地工作,在我的文件中我可以看到django文件夹 - 它的路径是: Message: Command failed: /bin/sh -c ./manage.py runserver Traceback (most recent call last): File "./manage.py", line 11, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management Details: killed: false code: 1 signal: null cmd: /bin/sh -c ./manage.py runserver stdout: stderr: Traceback (most recent call last): File "./manage.py", line 11, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management

完整错误如下所示:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os
import sys

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

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

我的manage.py看起来像这样:

/usr/bin/python

运行哪个python给我这个: python -c 'import sys; print sys.real_prefix' 2>/dev/null && INVENV=1 || INVENV=0

我不确定我是否在虚拟环境中运行。我正在做这个项目的前端,环境是由其他人为我设置和安装的 - 但是运行Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException: Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(Uri uri, UriQueryBuilder builder, IBufferManager bufferManager, Nullable`1 timeout, TableOperation operation, Boolean useVersionHeader, OperationContext ctx, TableRequestOptions options, String accountName) at Microsoft.WindowsAzure.Storage.Table.TableOperation.<>c__DisplayClass18.<RetrieveImpl>b__15(Uri uri, UriQueryBuilder builder, Nullable`1 timeout, Boolean useVersionHeader, OperationContext ctx) at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ProcessStartOfRequest[T](ExecutionState`1 executionState, String startLogMessage) at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) --- End of inner exception stack trace --- at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.TableOperation.Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.CloudTable.Exists(Boolean primaryOnly, TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext) at IpAddressDetect.Program.Main(String[] args) (另一篇文章建议检查我是否在虚拟环境中)没有返回任何内容。 / p>

我查看了其他一些帖子,看到有些人重新安装,其他人修改了路径,其他人说不编辑manage.py文件 - 但是因为我不确定问题是路径还是安装我不知道如何继续。如果您需要更多信息,请告诉我。

1 个答案:

答案 0 :(得分:2)

您错过了python包,这意味着您VirtualEnv未被激活。

VirtualEnv默认创建一个名为env的文件夹(虽然名称可以更改),它存储特定的python安装及其所有软件包。在项目文件夹中搜索activate bash脚本。一旦找到,您就可以找到它。

source ./env/bin/activate

为了完整起见,在Windows中它将是一个批处理文件。

env/bin/activate.bat

如果您的命令提示符以env名称为前缀,例如(env) Macbook user$,则您知道自己处于虚拟语言中。

您现在可以启动django测试服务器了。

python manage.py runserver

要停用,只需在命令提示符中随时键入deactivate即可。提示符上的(env)前缀应该消失。