GVKun编程网logo

Django-“没有名为django.core.management的模块”(没有名为numpy的模块)

15

本文将介绍Django-“没有名为django.core.management的模块”的详细情况,特别是关于没有名为numpy的模块的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了

本文将介绍Django-“没有名为django.core.management的模块”的详细情况,特别是关于没有名为numpy的模块的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于App Engine上的Django 1.7“ ImportError:没有名为msvcrt的模块”、Django - ModuleNotFoundError:没有名为“djangoformsetjs”的模块、Django Shell没有名为设置的模块、Django – 没有名为应用程序的模块的知识。

本文目录一览:

Django-“没有名为django.core.management的模块”(没有名为numpy的模块)

Django-“没有名为django.core.management的模块”(没有名为numpy的模块)

尝试从命令行运行Django时出现以下错误。

File manage.py, line 8, in <module>     from django.core.management import execute_from_command_lineImportError: No module named django.core.management

关于如何解决这个问题的任何想法?

答案1

小编典典

听起来你没有安装django。你应该检查此命令生成的目录:

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

看那里是否有django软件包。

如果站点软件包内没有django文件夹,则说明你没有安装django(至少对于该版本的python)。

可能你安装了多个版本的python,而django位于另一版本中。如果键入python然后按TAB键,则可以找出python的所有版本。这是我拥有的所有不同的python。

$pythonpython            python2-config    python2.6         python2.7-config  pythonw2.5python-config     python2.5         python2.6-config  pythonw           pythonw2.6python2           python2.5-config  python2.7         pythonw2          pythonw2.7

你可以对每个python版本执行上述命令,并查看每个版本的site-packages目录以查看其中是否安装了django。例如:

python2.5 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"python2.6 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

如果你碰巧在python2.6中找到django,请尝试使用以下原始命令

python2.6 manage.py ...

App Engine上的Django 1.7“ ImportError:没有名为msvcrt的模块”

App Engine上的Django 1.7“ ImportError:没有名为msvcrt的模块”

我正在尝试在Windows计算机上运行的Google App Engine开发服务器上将Django升级到1.7版。

尝试加载应用程序时,我从以下消息中得到以下异常doango\core\files\locks.py

ImportError: No module named msvcrt

相关的代码行是:

if os.name == ''nt'':    import msvcrt

我猜是因为App Engine的开发服务器未提供msvcrt的版本而引发异常,但是由于我的开发机是Windows,所以os.name仍然是''nt''

是否有解决方案或解决方法?

相关的堆栈跟踪:

 File "...\django\core\files\locks.py", line 30, in <module>    import msvcrt File "D:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 852, in load_module    raise ImportError(''No module named %s'' % fullname)

答案1

小编典典

刚刚找到了解决方法。在appengine_config.py添加以下行:

import oson_appengine = os.environ.get(''SERVER_SOFTWARE'','''').startswith(''Development'')if on_appengine and os.name == ''nt'':    os.name = None

我仍在寻找一种不那么骇人听闻的解决方案。

Django - ModuleNotFoundError:没有名为“djangoformsetjs”的模块

Django - ModuleNotFoundError:没有名为“djangoformsetjs”的模块

如何解决Django - ModuleNotFoundError:没有名为“djangoformsetjs”的模块?

我有一个新的 Django 应用,在我的 settings.py 中有以下模块:

INSTALLED_APPS = [
    ''djangoformsetjs'',''widget_tweaks'',''django.contrib.admin'',''django.contrib.auth'',''django.contrib.contenttypes'',''django.contrib.sessions'',''django.contrib.messages'',''django.contrib.staticfiles'',''django_hosts'',''rest_framework'',''djoser'',''app'',# Enable the inner app
    ''phonenumber_field'',]

尝试第一次上传到 Heroku 时,它返回错误:

ModuleNotFoundError: No module named ''djangoformsetjs''

虽然它在本地运行良好。我尝试从终端重新安装:pip install django-formset-js

一切似乎都很好:

Requirement already satisfied: django-formset-js in /Users/homepc/opt/anaconda3/lib/python3.8/site-packages (0.5.0)
Requirement already satisfied: django-jquery-js in /Users/homepc/opt/anaconda3/lib/python3.8/site-packages (from django-formset-js) (3.1.1)
Requirement already satisfied: Django in /Users/homepc/.local/lib/python3.8/site-packages (from django-formset-js) (2.2)
Requirement already satisfied: sqlparse in /Users/homepc/opt/anaconda3/lib/python3.8/site-packages (from Django->django-formset-js) (0.4.1)
Requirement already satisfied: pytz in /Users/homepc/opt/anaconda3/lib/python3.8/site-packages (from Django->django-formset-js) (2020.1)

请问我的设置中遗漏了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Django Shell没有名为设置的模块

Django Shell没有名为设置的模块

我已通过将Django部署到Django mod_wsgi。从Apache托管时,Django运行良好。但是,我试图通过进行一些维护manage.py,但是当我尝试运行它时,出现错误消息:

错误:无法导入设置“ myproject.settings”(在sys.path上吗?):没有名为设置的模块

user@localhost:~$ cd /usr/local/myproject
user@localhost:/usr/local/myproject$ ls
drwxr-xr-x 2 apache apache   4096 2011-09-07 19:38 apache
-rw-r--r-- 1 apache apache      0 2011-05-25 14:52 __init__.py
-rw-r--r-- 1 apache apache    813 2011-09-09 16:56 manage.py
drwxr-xr-x 6 apache apache   4096 2011-09-09 16:43 myapp
-rw-r--r-- 1 apache apache   4992 2011-09-07 19:31 settings.py
drwxr-xr-x 4 apache apache   4096 2011-09-08 20:32 templates
-rw-r--r-- 1 apache apache   1210 2011-09-08 14:49 urls.py

Django似乎忽略了DJANGO_SETTINGS_MODULE环境变量。

user@localhost:~$ cd /usr/local/myproject
user@localhost:/usr/local/myproject$ export DJANGO_SETTINGS_MODULE=settings
user@localhost:/usr/local/myproject$ python manage.py shell
Error: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named settings
user@localhost:/usr/local/myproject$ python
Python 2.6.5 (r265:79063,Apr 16 2010,13:57:41) 
[GCC 4.4.3] on linux2
Type "help","copyright","credits" or "license" for more information.
>>> import settings
>>> 

为了确认我没有发疯,我注释掉了manage.py中除import settings行外的所有内容,并正确运行了该行。

我也试着设置os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'sys.path.append('/usr/local/myproject')直接manage.py的顶部,都无济于事。

这里发生了什么?Django为什么使用错误的设置模块名称?这真让我抓狂。

Django – 没有名为应用程序的模块

Django – 没有名为应用程序的模块

我一直在试图用django编写一个应用程序 – 但它根本不工作。 我也一直在努力 – 它正在开发完美的开发服务器。 但是我无法投入生产环境(apahce)。

我的项目名称是apstat,应用程序名称是基本的。

我尝试访问它如下

Blockquote http://主机名/ apstat

我将如何在.htaccess文件中编写if – elseif – elseif条件块?

无法启动Macbook上的XAMPP Apache服务器

Apache .htacces重写规则以删除.PHP文件扩展名

使用redirect从url中移除.html

透明redirect到端口8080

但它显示以下错误:

MOD_PYTHON ERROR ProcessId: 6002 Interpreter: ''domU-12-31-39-06-DD-F4.compute-1.internal'' ServerName: ''domU-12-31-39-06-DD-F4.compute-1.internal'' DocumentRoot: ''/home/ubuntu/server/'' URI: ''/apstat/'' Location: ''/apstat'' Directory: None Filename: ''/home/ubuntu/server/apstat/'' PathInfo: '''' Phase: ''PythonHandler'' Handler: ''django.core.handlers.modpython'' Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/mod_python/importer.py",line 1537,in Handlerdispatch default=default_handler,arg=req,silent=hlist.silent) File "/usr/lib/python2.6/dist-packages/mod_python/importer.py",line 1229,in _process_target result = _execute_target(config,req,object,arg) File "/usr/lib/python2.6/dist-packages/mod_python/importer.py",line 1128,in _execute_target result = object(arg) File "/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py",line 228,in handler return ModPythonHandler()(req) File "/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py",line 201,in __call__ response = self.get_response(request) File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",line 134,in get_response return self.handle_uncaught_exception(request,resolver,exc_info) File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",line 154,in handle_uncaught_exception return debug.technical_500_response(request,*exc_info) File "/usr/lib/pymodules/python2.6/django/views/debug.py",line 40,in technical_500_response html = reporter.get_traceback_html() File "/usr/lib/pymodules/python2.6/django/views/debug.py",line 114,in get_traceback_html return t.render(c) File "/usr/lib/pymodules/python2.6/django/template/__init__.py",line 178,in render return self.nodelist.render(context) File "/usr/lib/pymodules/python2.6/django/template/__init__.py",line 779,in render bits.append(self.render_node(node,context)) File "/usr/lib/pymodules/python2.6/django/template/debug.py",line 81,in render_node raise wrapped TemplateSyntaxError: Caught an exception while rendering: No module named basic Original Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/template/debug.py",line 71,in render_node result = node.render(context) File "/usr/lib/pymodules/python2.6/django/template/debug.py",line 87,in render output = force_unicode(self.filter_expression.resolve(context)) File "/usr/lib/pymodules/python2.6/django/template/__init__.py",line 572,in resolve new_obj = func(obj,*arg_vals) File "/usr/lib/pymodules/python2.6/django/template/defaultfilters.py",line 687,in date return format(value,arg) File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py",line 269,in format return df.format(format_string) File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py",line 30,in format pieces.append(force_unicode(getattr(self,piece)())) File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py",line 175,in r return self.format(''D,j MYH:i:s O'') File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py",piece)())) File "/usr/lib/pymodules/python2.6/django/utils/encoding.py",in force_unicode s = unicode(s) File "/usr/lib/pymodules/python2.6/django/utils/functional.py",in __unicode_cast return self.__func(*self.__args,**self.__kw) File "/usr/lib/pymodules/python2.6/django/utils/translation/__init__.py",line 62,in ugettext return real_ugettext(message) File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py",line 286,in ugettext return do_translate(message,''ugettext'') File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py",line 276,in do_translate _default = translation(settings.LANGUAGE_CODE) File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py",line 194,in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py",line 180,in _fetch app = import_module(appname) File "/usr/lib/pymodules/python2.6/django/utils/importlib.py",line 35,in import_module __import__(name) ImportError: No module named basic

我的settings.py如下所示:

INSTALLED_APPS = ( ''django.contrib.auth'',''django.contrib.contenttypes'',''django.contrib.sessions'',''django.contrib.sites'',''apstat.basic'',''django.contrib.admin'',)

如果我删除apstat.basic,它会通过,但这不是一个解决scheme。 这是我在做apache的东西吗?

我的Apache – 设置是 –

<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/ubuntu/server/ <Directory /> Options None AllowOverride None </Directory> <Directory /home/ubuntu/server/apstat> AllowOverride None Order allow,deny allow from all </Directory> <Location "/apstat"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE apstat.settings Pythonoption django.root /home/ubuntu/server/ PythonDebug On PythonPath "[''/home/ubuntu/server/''] + sys.path" </Location> </VirtualHost>

我现在坐了一天以上。 如果有人能帮助我,这将是非常好的。

禁用Apache / 2.0.52上的TRACE请求方法

得到了这个文件localhost_access_log.2014-08-30.txt访问被拒绝的Apache Tomcat错误?

如何检查Apache正在寻找一个PHP.ini文件?

.htaccess使用GET参数redirect

在同一台机器上的Wamp和xampp

你的基础是否有__init__.py ?

您需要确保项目在您的PYTHONPATH 。 也许尝试在设置文件的顶部输出sys.path变量:

import sys print sys.path

如果这不适用于mod_python尝试将其写入文件:

import sys file(''/tmp/mysyspath.txt'',''w'').write(repr(sys.path))

但即使这样做会有效,下面是一个简短的警告:django社区不鼓励使用mod_python 。 它不再由其创建者维护,从来也不是部署django项目的最佳解决方案。 请尝试mod_wsgi如果它在您的服务器上可用。

正常情况下,项目目录被添加到sys.path ,然后应用程序名称直接在INSTALLED_APPS和其他应用程序的导入中使用。 试试这个。

总结

以上是小编为你收集整理的Django – 没有名为应用程序的模块全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

今天的关于Django-“没有名为django.core.management的模块”没有名为numpy的模块的分享已经结束,谢谢您的关注,如果想了解更多关于App Engine上的Django 1.7“ ImportError:没有名为msvcrt的模块”、Django - ModuleNotFoundError:没有名为“djangoformsetjs”的模块、Django Shell没有名为设置的模块、Django – 没有名为应用程序的模块的相关知识,请在本站进行查询。

本文标签: