姜戈 + Virtualenv:manage.py 命令失败,并出现项目名称的 ImportError

发布于 2024-08-24 23:31:35 字数 613 浏览 3 评论 0原文

这让我大吃一惊,因为这可能是一个简单的解决方案,但我不知道是什么原因造成的。

所以我有一个新的开发盒并正在设置一切。我安装了 virtualenv,在 ~/.virtualenvs/projectname 下为我的项目创建了一个新环境,

然后,我将我的项目从 github 克隆到我的项目目录中。这里没什么特别的。周围没有 .pyc 文件,因此它是一个干净的代码。

然后,我激活了 virtualenv 并通过 pip 安装了 Django。到目前为止一切看起来都很好。

然后,我在项目目录中运行 python manage.pysyncdb 。这就是我感到困惑的地方:

 ImportError: No module named projectname

所以我想我的代码中可能有一些项目名称的引用。所以我 grep(实际上是 ack)我的代码库,但没有找到任何类似的东西。

所以现在我不知所措,考虑到这种环境,为什么我会在代码中没有引用的名为 projectname 的模块上收到 ImportError ?

我期待一个解决方案..谢谢大家!

This is blowing my mind because it's probably an easy solution, but I can't figure out what could be causing this.

So I have a new dev box and am setting everything up. I installed virtualenv, created a new environment for my project under ~/.virtualenvs/projectname

Then, I cloned my project from github into my projects directory. Nothing fancy here. There are no .pyc files sitting around so it's a clean slate of code.

Then, I activated my virtualenv and installed Django via pip. All looks good so far.

Then, I run python manage.py syncdb within my project dir. This is where I get confused:

 ImportError: No module named projectname

So I figured I may have had some references of projectname within my code. So I grep (ack, actually) through my code base and I find nothing of the sorts.

So now I'm at a loss, given this environment why am I getting an ImportError on a module named projectname that isn't referenced anywhere in my code?

I look forward to a solution .. thanks guys!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

半世晨晓 2024-08-31 23:31:35

项目名称(模数后缀)是否与项目所在目录的名称完全相同?疯狂猜测,但我知道 Django 对当前目录做了一些事情……

另外,什么试图导入项目名称?你有回溯吗?如果没有,请尝试使用 py manage.py --tracebacksyncdb 运行,看看会发生什么。

Is projectname exactly (modulo suffix) the name of the directory the project is in? Wild guess, but I know Django does some things with the current directory…

Also, what is trying to import projectname? Do you get a traceback? If not, try running with py manage.py --traceback syncdb and see what happens.

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