2014-03-01 47 views
0

我在PyPi上遇到了Python包问题。我看不出这样的问题,任何回答问题(虽然我已经发现了一些悬而未决的),所以这里有云:安装新的Pypi模块看起来不错,但不被python识别?

我的包BrickPython看起来是这样的:

BrickPython 
    + BrickPython 
     + __init__.py 
     + Scheduler.py 
    + Other test and example modules at top level. 

该模块具有工作setup.py;包的BrickPython似乎正确安装在PyPi上(使用python setup.py sdist upload);和

sudo pip install BrickPython 

成功完成。然而,当我尝试使用它,我看到错误:

>>> import BrickPython 
>>> BrickPython.Motor 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: 'module' object has no attribute 'Motor' 

至于我能看到我下面类似http://guide.python-distribute.org/creation.html#directory-layout设置(所有测试代码是在不同的地方),所以我米想知道什么是错的。这是很痛苦的尝试,因为显然我必须制作一个新版本来测试我所做的每一项变更。

1)如何与鸡蛋包的安装试验而通过的PyPI安装回事?

2)我应该怎么做才能使它工作?

  • 查尔斯
+0

你有'BrickPython/BrickPython/Motor.py'文件?你在'BrickPython/BrickPython/__ init __。py'中导入'BrickPython.Motor'吗? – jfs

+0

*“如何在不通过PyPi安装的情况下试验蛋包安装?”*使用'setup.py'在目录中运行'pip install -e .'。 – jfs

+0

啊哈,太棒了!谢谢J.F. – CharlesW

回答

0

试试这个

from BrickPython import Motor 

m = Motor.Motor(<port>, [scheduler]) 
+0

是的 - 有效。我对Python导入语法的误解。通常情况下,它将成为'从BrickPython.Motor导入电机... m =电机(0)'。非常感谢! - Charles – CharlesW