Python 与 Sage 的导入错误
好吧,我对 python 比较陌生,一直在研究这个问题,但我找不到类似的东西,所以我不确定发生了什么。
我正在创建一个涉及圣人的程序,它有一个消息提示。我们在开发机器上设置了这个,所以我知道它可以工作,但我想在我自己的计算机上设置它,这样我可以更好地了解它是如何工作的,并让我自己开发更容易。
为了启动 sage,我们运行一个脚本,该脚本调用 sages 主二进制文件并向其传递一个可执行的 .py 文件。 (./sage/sage ./sage_server.py) 这会在 sage_server.py 文件中创建一个错误:
Traceback (most recent call last):
File "./sage_server.py", line 23, in <module>
from carrot.messaging import Publisher
ImportError: No module named carrot.messaging
但是每当我在终端 (./sage_server) 中运行该文件时,导入工作正常,直到第 27 行当它尝试从 sage 导入某些内容时出现错误。
有谁知道当它被其他东西调用时会导致错误吗?我非常不知道是什么原因造成的。
Okay I am newer to python and have been researching this problem but I can't find anything like it so I am not sure what is going on.
I am creating a program that involves sage and it has a message cue. We have this set up on a development machine, so I know it works but I was wanting to set it up on my own computer so I could get a better understanding of how it all works and make it easier to develop for myself.
To start up sage, we run a script that calls sages main binary file and passes it an executable .py file. (./sage/sage ./sage_server.py) This creates an error in the sage_server.py file:
Traceback (most recent call last):
File "./sage_server.py", line 23, in <module>
from carrot.messaging import Publisher
ImportError: No module named carrot.messaging
But whenever I run that file just in the terminal (./sage_server) the import works fine and isn't until line 27 that there is an error when it tries to import something from sage.
Does anyone know what would cause the error when it is being called by something else? I am very lost as to what would be causing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sage 有自己的 python,与系统库分开。这个“carrot”模块,无论它是什么,都必须安装在 python
./sage_server.py
使用的任何地方,但不能安装在 Sage 中。您应该能够
启动 Sage shell 并使用 easy_install,或者您可以获取您正在使用的任何 carroty 软件包,找到其 setup.py 文件,然后在
显然您的位置 运行 -圣人是通往圣人的道路。
如果安装过程不是基于 setup.py 的,事情会变得有点棘手。
Sage has its own python, separate from the system libraries. This "carrot" module, whatever it is, must be installed in whatever python
./sage_server.py
uses, but not in Sage.You should be able to use either
to start up a Sage shell and use easy_install, or you could get whatever carroty package you're using, find its
setup.py
file, and then runwhere obviously your-sage is the path to your sage.
Things get a little trickier if the install process isn't setup.py-based.