manage.py runserver - 导入错误:没有名为 MYSITE 的模块

发布于 2024-10-26 00:51:19 字数 434 浏览 1 评论 0原文

我无法运行开发环境!

我一直按照此处(教程在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

下壹個目標 2024-11-02 00:51:19

如果您使用的是 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 called PYTHONPATH.

零度℉ 2024-11-02 00:51:19

由于这在 Google 上排名很高,而且我在寻找答案时来到这里,我将分享我的解决方案:

我在我的机器上构建了一个项目,打包到 debian 包中并安装在测试机器上。在我的机器上我使用 runserver 但在测试机器上我使用 apache (使用得很好)。当将数据库从 sqlite 更改为 postgresql 时,我无法执行 shell 或syncdb 等(所有管理命令)。这里的问题是,manage.py 属于 www-data,并且它必须是 root 才能使这些命令起作用......

sudo chown root. manage.py

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...

sudo chown root. manage.py
提笔书几行 2024-11-02 00:51:19

另一个不同的答案;)我正在阅读“Python Web Development with Django”中的“Django for the Impressive: Building a Blog”一章,它建议创建一个“dotted”模块,所以我将我的应用程序注册为“xy”,但它没有不喜欢。更改为与文件系统匹配的“y”:

/x
 + manage.py
 + /x
   + settings.py
 + /y
   + models.py

为我工作。

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:

/x
 + manage.py
 + /x
   + settings.py
 + /y
   + models.py

Worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文