arachnidlabs / minishift-python

Python library for interfacing with the minishift.
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

minishift pip fails - mising HID #2

Open adamboutcher opened 10 years ago

adamboutcher commented 10 years ago

Hi,

I'm running Debian Wheezy and after I've run pip install minishift-python and attempt to run the daemon, python then states there is no module hid.

pip install hid fails too.

adamboutcher commented 10 years ago

Depends on the following, which should really be mentioned somewhere:

python-dev cython hidapi libudev-dev libusb-1.0-0 libusb-1.0-0-dev

I might be missing something else as the scroller works fine on Mint Debian Edition on a PC but on the RaspberryPi with a tiny debian, python crashes. Any ideas?

TBSliver commented 10 years ago

Hi,

Am having the same issue here. after running the following commands:

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo pip install minishift-python
sudo apt-get install python-dev cython libhidapi-dev libudev-dev libusb-1.0-0 libusb-1.0-0-dev

I get the following error when trying to run a 9 block wide minishift:

tbsliver at polygon in ~/Projects/minishift 
$ python -m minishift.minishiftd 72
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 156, in <module>
    main(args)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 126, in main
    interface = MCP2210Interface(int(args.vid), int(args.pid))
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 21, in __init__
    import mcp2210
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/__init__.py", line 2, in <module>
    from mcp2210.device import MCP2210, CommandException
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 1, in <module>
    import hid
ImportError: No module named hid

This is what happens when i try to install the hid module:

tbsliver at polygon in ~/Projects/minishift 
$ sudo pip install hid
Downloading/unpacking hid
  Downloading hid-0.1.0.tar.gz
  Running setup.py (path:/tmp/pip_build_root/hid/setup.py) egg_info for package hid
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/hid/setup.py", line 5, in <module>
        README = open(os.path.join(here, 'README.md')).read()
    IOError: [Errno 2] No such file or directory: '/tmp/pip_build_root/hid/README.md'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/hid/setup.py", line 5, in <module>

    README = open(os.path.join(here, 'README.md')).read()

IOError: [Errno 2] No such file or directory: '/tmp/pip_build_root/hid/README.md'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/hid
Storing debug log for failure in /root/.pip/pip.log

This is the contents of /root/.pip/pip.log:

Downloading/unpacking hid
  Getting page https://pypi.python.org/simple/hid/
  URLs to search for versions for hid:
  * https://pypi.python.org/simple/hid/
  Analyzing links from page https://pypi.python.org/simple/hid/
    Found link https://pypi.python.org/packages/source/h/hid/hid-0.1.0.tar.gz#md5=09a8ece671f1d6f14d82e4d1305eb6de (from https://pypi.python.org/simple/hid/), version: 0.1.0
  Downloading hid-0.1.0.tar.gz
  Downloading from URL https://pypi.python.org/packages/source/h/hid/hid-0.1.0.tar.gz#md5=09a8ece671f1d6f14d82e4d1305eb6de (from https://pypi.python.org/simple/hid/)
  Running setup.py (path:/tmp/pip_build_root/hid/setup.py) egg_info for package hid
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/hid/setup.py", line 5, in <module>
        README = open(os.path.join(here, 'README.md')).read()
    IOError: [Errno 2] No such file or directory: '/tmp/pip_build_root/hid/README.md'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/hid/setup.py", line 5, in <module>

    README = open(os.path.join(here, 'README.md')).read()

IOError: [Errno 2] No such file or directory: '/tmp/pip_build_root/hid/README.md'

----------------------------------------
Cleaning up...
  Removing temporary dir /tmp/pip_build_root...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/hid
Exception information:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python2.7/dist-packages/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/hid

Any ideas?

adamboutcher commented 10 years ago

I've managed to mangle it together, iirc it needs hid a pi from pip ( pip install hidapi ) which is a pain to get installed.

I currently have an issue on my pi where scrolling crashes the web daemon.

TBSliver commented 10 years ago

Right, after more investigation I managed to fix the issue. I was trying to install the wrong module which uses the same namespace as another module - hence nothing working.

The module you want is hidapi, a cython module. install it with the following command:

sudo pip install hidapi

And then the minishiftd should work.

If you have the 'hid' module installed, then you will need to remove it. If you installed it through pip, then run

sudo pip uninstall hid

If you installed it from source, then you can remove it using the two following commands:

sudo python setup.py install --record files.txt
cat files.txt | sudo xargs rm -rf

Or any other method your happy with.

This also makes it work on a Pi, although i find that the server script crashes after a short while.

adamboutcher commented 10 years ago

Has anyone managed to get a stable server script running?

Arachnid commented 10 years ago

Sorry folks, gmail miscategorised this, so I only just saw it. If the daemon is crashing for you, can you please paste a stacktrace?

I'll add more docs on dependencies shortly.

TBSliver commented 10 years ago

It works when running on a machine which is powerful enough - for example my desktop. However I think theres something wrong with one of the libraries trying to run it on a Pi which causes the crash. Will get a stacktrace next time I have a chance to run it on a Pi!

adamboutcher commented 10 years ago

How do you get a stacktrace and I'll try and do it now, I'm not a python dev so I dont know how.

Arachnid commented 10 years ago

Run minishiftd without the '-d' argument (so it just sits there taking up your terminal while it runs); if the process crashes it will print the stacktrace to the console you ran it in.

adamboutcher commented 10 years ago

oh, in that case, there isn't anything displayed... it just kind of freezes.

Arachnid commented 10 years ago

Hm, okay. What does it print when you press Control+C?

adamboutcher commented 10 years ago

nothing, it's frozen completely. I have to open up another terminal and kill the process.

TBSliver commented 10 years ago

I found actually unplugging the Minishift made it respond when that happened

TBSliver commented 10 years ago

Ok, so I quickly plugged it in and got the stacktraces. Both of these are retrieved by running the following command in one window:

$ python -m minishift.minishiftd 72

And this one in another window:

$ curl -G http://localhost:8000/set --data-urlencode "text=To be or not to be, that is the question" -d interval=0.05

This first stacktrace is what happens when, after it stalls, you pull the plug and then press Ctrl-C

$ python -m minishift.minishiftd 72
INFO:root:Serving on 8000
/set?text=To%20be%20or%20not%20to%20be%2C%20that%20is%20the%20question&interval=0.05
127.0.0.1 - - [17/Jun/2014 16:38:00] "GET /set?text=To%20be%20or%20not%20to%20be%2C%20that%20is%20the%20question&interval=0.05 HTTP/1.1" 200 -
/set?text=Carrot%20and%20cheese%2C%20thats%20what%20we%20need&interval=0.05
127.0.0.1 - - [17/Jun/2014 16:39:00] "GET /set?text=Carrot%20and%20cheese%2C%20thats%20what%20we%20need&interval=0.05 HTTP/1.1" 200 -
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 41, in run
    self.do_scroll_text(self.text, self.scroll_interval, self.scroll_times)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 51, in do_scroll_text
    self.minishift.update(col)
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 192, in update
    self.interface.send(canvas.to_bytes())
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 25, in send
    self.device.transfer(data)
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 214, in transfer
    response += self.sendCommand(commands.SPITransferCommand(data[i:i + 60])).data
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 137, in sendCommand
    response = command.RESPONSE.from_buffer_copy(response_data)
ValueError: Buffer size too small (0 instead of at least 64 bytes)

^CTraceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 156, in <module>
    main(args)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 146, in main
    httpd.serve_forever()
  File "/usr/lib/python2.7/SocketServer.py", line 236, in serve_forever
    poll_interval)
  File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry
    return func(*args)
KeyboardInterrupt

This second stacktrace is what happens when, after it has stalled, you press Ctrl-C and then unplug the minishift (just incase theres any difference at all)

$ python -m minishift.minishiftd 72
INFO:root:Serving on 8000
/set?text=To%20be%20or%20not%20to%20be%2C%20that%20is%20the%20question&interval=0.05
127.0.0.1 - - [17/Jun/2014 16:40:15] "GET /set?text=To%20be%20or%20not%20to%20be%2C%20that%20is%20the%20question&interval=0.05 HTTP/1.1" 200 -
^CTraceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 156, in <module>
    main(args)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 146, in main
    httpd.serve_forever()
  File "/usr/lib/python2.7/SocketServer.py", line 236, in serve_forever
    poll_interval)
  File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry
    return func(*args)
KeyboardInterrupt
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 41, in run
    self.do_scroll_text(self.text, self.scroll_interval, self.scroll_times)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 51, in do_scroll_text
    self.minishift.update(col)
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 192, in update
    self.interface.send(canvas.to_bytes())
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 25, in send
    self.device.transfer(data)
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 218, in transfer
    response += self.sendCommand(commands.SPITransferCommand('')).data
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 137, in sendCommand
    response = command.RESPONSE.from_buffer_copy(response_data)
ValueError: Buffer size too small (0 instead of at least 64 bytes)

Hopefully these are helpful.

Note that with both of these, when it actually stalls the minishift just stops scrolling more data in, and there is no error shown on the terminal window.

emilepetrone commented 10 years ago

I too got the error "ImportError: No module named hid" . To solve this:

pip install minishift-python, Cython, hidapi

Then you can run through the rest of the tutorial without trouble.

adamboutcher commented 9 years ago

Has anyone got any further with this issue?

I'm still having this problem on Debian Wheezy (Kernel 3.6.11 armhf) and Python 2.7.3

Arachnid commented 9 years ago

Can you try "pip uninstall minishift-python" "pip uninstall hid" and try again? I thought this issue was resolved with the latest setup.py.

adamboutcher commented 9 years ago

It still seems to crash/hang on the raspberry pie with the latest minishift-python, this is more noticeable when you introduce scrolling. Again, there's no crash output until you remove the minishift which is the same as @TBSliver has previously mentioned. Nothing in dmesg, syslog or messages.

This doesn't seem to happen on a x86/x64 based CPU

Arachnid commented 9 years ago

That's a separate issue from not being able to install hid. Can you open a separate issue with any details you have?

ComputerSmiths commented 9 years ago

Seems to work OK on a Raspberry Pi 2, see the other issue for details of what to load.