seabreeze(seabreeze)とpyseabreeze(pyseabreeze)を使用してOcean光学分光器とのインターフェースを試みています。Pythonコードは対話型プロンプトで実行されますが、スクリプトとしては実行されません
Windowsのコマンドプロンプト(cmd)からpythonを入力し、次のコードを1行ずつ入力すると動作します。しかし、私がスクリプト(spec_test.py)に入れ、 'python spec_test.py'を使ってcmd.exeから実行しようとすると、動作しません。
私は同様の問題についてたくさん検索しましたが、私が持っている問題をカバーするものはありません。私はWindows 7 64ビット、python 3.5.2、anacondaを使ってインストールしています。 pysebreezeを使うためにpyusbとlibusbをインストールしなければならなかった。
コード:
import seabreeze
seabreeze.use('pyseabreeze')
import seabreeze.spectrometers as sb
devs = sb.list_devices()
print(devs)
spec = sb.Spectrometer(devs[0])
print(spec.model)
と私が取得エラーメッセージ:任意の助け
[<SeaBreezeDevice USB2000PLUS:FLMS02379>]
Traceback (most recent call last):
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\common.py", line 14, in decorated_func
return func(*args, **kwargs)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\spectrometer.py", line 46, in open
self.open_device(device.handle)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\communication.py", line 37, in open_device
device.set_configuration()
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
_check(_lib.usb_set_configuration(dev_handle, config_value))
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'
Traceback (most recent call last):
File "<ipython-input-9-ead886eb3666>", line 1, in <module>
runfile('C:/Users/Raman Lab/Python code/Spectrometers/spec_testing.py', wdir='C:/Users/Raman Lab/Python code/Spectrometers')
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Raman Lab/Python code/Spectrometers/spec_testing.py", line 7, in <module>
spec = sb.Spectrometer(devs[0])
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\spectrometers.py", line 62, in __init__
self._open_device(device)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\spectrometers.py", line 90, in _open_device
lib.device_open(self._dev)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\wrapper.py", line 81, in device_open
return device.interface.open(device)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\common.py", line 23, in decorated_func
raise SeaBreezeError(msg)
SeaBreezeError: An error occured during opening.
ありがとう!
編集: 何らかの理由で私はこれを理解して、問題の説明に役立つと考えました。私がcmd.exeからインタラクティブなpythonに入り、手動で入力するのではなくコードを貼り付けると、同じエラーが発生します。これは、私が(おそらく私が間違っている)と考えて、それは何とか輸入のスピードと結びついていると思う。私は、プロンプトで入力したときに何が起こるかをシミュレートするために、3行目と5行目の間に数秒間スリープ状態を追加しようとしましたが、それは助けになりませんでした。私はこれが十分記述的であったことを望む。
パスの問題のようです。必要なDLLがパスに含まれていることを確認してください。 – MiltoxBeyond
私はそのコードがそのエラーメッセージを生成したとは思わない。トレースバックの最初の行にはspec_sample_plot.py、10行目が記載されています。提供したコードは8行しかありません。エラーを生成した* exact *プログラムをコピーして貼り付けてください。 –
@ Rob codeコードには、私がここに投稿していないいくつかのコメントがあり、行番号の不一致を説明しています。私は、このコードだけのエラーの読み取りを含めるために投稿を編集しました。 –