LoginSignup
0
0

More than 3 years have passed since last update.

HIDデバイスをconda環境で実行

Last updated at Posted at 2019-05-24

http://akizukidenshi.com/catalog/g/gM-05131/
http://km2net.com/usb-io2.0/index.shtml
こちらのデバイスを使うと、様々なセンサやアクチュエータをパソコンから直接制御できて便利。
pythonで制御する場合、import hidpip install hidapiでインストール。https://github.com/trezor/cython-hidapi)
でインポートし、プログラムを書く。

問題点

そのファイルを実行する際に、devへの権限がrootでないと得られないので
sudo python xxx.py
で実行しなければならない。
しかし、bearという仮想環境上で動かしたい。
sudo python(bear) pythonで参照する先のpythonが違い、困った。

(bear) username@username:~$ which python
/home/username/PythonVirtualEnvironments/DefaultEnv3.7/bin/python

(bear) username@username:~$ sudo which python
/usr/bin/python

解決法

bear仮想環境上でwhich pythonと打ち
出てきた先のパスをコピペ。

上記のように出たので、

(bear) username@username:~$ sudo /home/username/PythonVirtualEnvironments/DefaultEnv3.7/bin/python xxx.py

で問題なく実行できた。
今は、devへのアクセス権限のあるグループを変更することを検討中。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0