manage.py runserver - 导入错误:没有名为 MYSITE 的模块
我无法运行开发环境!
我一直按照此处(教程在 DjangoProject 页面上)。当我输入时,
manage.py runserver
出现以下错误:
ImportError: No module named MYSITE
我正在 MYSITE 文件夹中执行命令,其中包含文件 init.py、manage.py、settings.py、urls.py
我四处搜索并发现了有关“manage.py”的问题runserver”,但不是这个特定的错误。非常感谢您的帮助。谢谢
I can't get the dev environment running!
I've been following the instructions here (tutorial on DjangoProject page). When I type
manage.py runserver
I get the following error:
ImportError: No module named MYSITE
I am executing the command within the folder MYSITE which has the files init.py, manage.py, settings.py, urls.py
I've searched around and found questions on "manage.py runserver", but not this specific error. Your help is greatly appreciated. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 Windows,则需要将项目目录(其中包含
manage.py
的目录)放入名为PYTHONPATH
的环境变量中。If you're using windows, you'll need to put your project's directory (the one with
manage.py
in it) into an environment variable calledPYTHONPATH
.由于这在 Google 上排名很高,而且我在寻找答案时来到这里,我将分享我的解决方案:
我在我的机器上构建了一个项目,打包到 debian 包中并安装在测试机器上。在我的机器上我使用 runserver 但在测试机器上我使用 apache (使用得很好)。当将数据库从 sqlite 更改为 postgresql 时,我无法执行 shell 或syncdb 等(所有管理命令)。这里的问题是,manage.py 属于 www-data,并且它必须是 root 才能使这些命令起作用......
Since this is highly ranked on Google and I got here while searching for an answer I'll share my solution:
I have a project built on my machine, packaged into a debian package and installed on a test machine. On my machine I use the runserver but on the testmachine I use apache (which was using fine). When changing database from sqlite to postgresql I could not do shell or syncdb etc (all manage commands). The problem here was that manage.py was owned by www-data and it had to be root for these commands to work...
另一个不同的答案;)我正在阅读“Python Web Development with Django”中的“Django for the Impressive: Building a Blog”一章,它建议创建一个“dotted”模块,所以我将我的应用程序注册为“xy”,但它没有不喜欢。更改为与文件系统匹配的“y”:
为我工作。
Another different answer ;) I'm walking the "Django for the Impatient: Building a Blog" chapter from "Python Web Development with Django" and it suggests creating a "dotted" module so I registered my application as "x.y" which it didn't like. Changing to "y" which matched the file-system as:
Worked for me.