0

I'm having trouble with a Python package on PyPi. I can't see any answered questions for problems like this (though I've found some unanswered ones), so here goes:

My package BrickPython looks like this:

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

The module has a working setup.py; package BrickPython appears to be correctly installed on PyPi (using python setup.py sdist upload); and

sudo pip install BrickPython

completes successfully. However when I attempt to use it, I see errors:

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

As far as I can see I'm following the setup similar to http://guide.python-distribute.org/creation.html#directory-layout (for all the test code is in a different place), so I'm wondering what can be wrong. It's painful to experiment with this, as apparently I have to make a new release to test each change I make.

Please,

1) How can I experiment with egg package installation without going through PyPi installations?

2) What should I do to make it work?

  • Charles
CharlesW
  • 955
  • 8
  • 18
  • Do you have `BrickPython/BrickPython/Motor.py` file? Do you import `BrickPython.Motor` in `BrickPython/BrickPython/__init__.py`? – jfs Mar 01 '14 at 23:17
  • *"How can I experiment with egg package installation without going through PyPi installations?"* run `pip install -e .` in the directory with `setup.py`. – jfs Mar 01 '14 at 23:19
  • Aha, great! Thank you J.F. – CharlesW Mar 02 '14 at 16:56

1 Answers1

0

Give this a try

from BrickPython import Motor

m = Motor.Motor(<port>, [scheduler])
kzorro
  • 1,682
  • 2
  • 11
  • 4
  • Yes - that works. My misunderstanding of Python import syntax. More usually it would become `from BrickPython.Motor import Motor ... m=Motor(0)`. Many thanks! - Charles – CharlesW Mar 02 '14 at 16:50