【发布时间】:2016-12-18 13:18:12
【问题描述】:
Python 和 Ipython 版本:
- 笔记本服务器的版本是
3.0.0-f75fda4。 - Python
2.7.9|Anaconda2.2.0(64 位)|
问题描述
我在 Python 中使用 undaqtools 模块。包裹页面是here。该软件包包含将数据采集文件 (DAQ) 从驾驶模拟器输出转换为 HDF5 格式的功能。根据包页面有两种方法可以做到这一点。一种方法是使用函数daq.read 和daq.write_hd5 逐个转换文件。我已经使用了几次,它完美无缺。第二种方法是使用脚本undaq.py同时批量转换多个DAQ文件。该脚本位于 C 盘 (Windows 7) 中的 /Anaconda/Scripts/ 中。我在DrivingSimulator/Data 文件夹中有 3 个 DAQ 文件,命名为:
- 汽车_20160601_01
- 汽车_20160601_02
- 汽车_20160601_03
所以,我首先将目录更改为DrivingSimulator/Data。然后根据包的Getting Started页面,在IPython中尝试undaq.py *命令,报错:
%run C:/Users/durraniu/Anaconda/Scripts/undaq.py *
usage: undaq.py [-h] [-n NUMCPU] [-o OUTTYPE] [-e ELEMFILE] [-r] [-d] path
undaq.py: error: unrecognized arguments: Cars_20160601_02.daq Cars_20160601_03.daq
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
这是完整的回溯:
%tb
---------------------------------------------------------------------------
SystemExit Traceback (most recent call last)
C:\Users\durraniu\Anaconda\lib\site-packages\IPython\utils\py3compat.pyc in execfile(fname, glob, loc, compiler)
205 filename = fname
206 compiler = compiler or compile
--> 207 exec(compiler(scripttext, filename, 'exec'), glob, loc)
208
209 else:
C:\Users\durraniu\Anaconda\lib\site-packages\undaqtools-0.2.3-py2.7.egg\EGG-INFO\scripts\undaq.py in <module>()
2 # EASY-INSTALL-SCRIPT: 'undaqtools==0.2.3','undaq.py'
3 __requires__ = 'undaqtools==0.2.3'
----> 4 __import__('pkg_resources').run_script('undaqtools==0.2.3', 'undaq.py')
C:\Users\durraniu\Anaconda\lib\site-packages\setuptools-18.4-py2.7.egg\pkg_resources\__init__.py in run_script(self, requires, script_name)
733 ns.clear()
734 ns['__name__'] = name
--> 735 self.require(requires)[0].run_script(script_name, ns)
736
737 def __iter__(self):
C:\Users\durraniu\Anaconda\lib\site-packages\setuptools-18.4-py2.7.egg\pkg_resources\__init__.py in run_script(self, script_name, namespace)
1657 )
1658 script_code = compile(script_text, script_filename,'exec')
-> 1659 exec(script_code, namespace, namespace)
1660
1661 def _has(self, path):
C:\Users\durraniu\Anaconda\lib\site-packages\undaqtools-0.2.3-py2.7.egg\EGG-INFO\scripts\undaq.py in <module>()
C:\Users\durraniu\Anaconda\lib\argparse.pyc in parse_args(self, args, namespace)
1702 if argv:
1703 msg = _('unrecognized arguments: %s')
-> 1704 self.error(msg % ' '.join(argv))
1705 return args
1706
C:\Users\durraniu\Anaconda\lib\argparse.pyc in error(self, message)
2372 """
2373 self.print_usage(_sys.stderr)
-> 2374 self.exit(2, _('%s: error: %s\n') % (self.prog, message))
C:\Users\durraniu\Anaconda\lib\argparse.pyc in exit(self, status, message)
2360 if message:
2361 self._print_message(message, _sys.stderr)
-> 2362 _sys.exit(status)
2363
2364 def error(self, message):
SystemExit: 2
我无法理解这个错误。另外,我尝试在 CMD 中使用undaq.py,但打开了一个新窗口,提示 Windows 无法打开此文件:
请让我知道我做错了什么?另外,请注意Script文件夹和Python的路径已经在系统变量的PATH变量中。
更新:
按照@hpaulj 的指示,我做了以下操作:
## Changing to the directory containing DAQ files:
%cd C:/Users/durraniu/Documents/DrivingSimulator/Data
## Running the undaq.py script:
%run C:/Users/durraniu/Anaconda/Scripts/undaq.py -r -d \\*
这给了我以下输出:
Glob Summary
--------------------------------------------------------------------
hdf5
daq size (KB) exists
--------------------------------------------------------------------
--------------------------------------------------------------------
debug = True
rebuild = True
Converting daqs with 1 cpus (this may take awhile)...
Debug Summary
Batch processing completed.
--------------------------------------------------------------------
Conversion Summary
--------------------------------------------------------------------
Total elapsed time: 0.1 s
Data converted: 0.000 MB
Data throughput: 0.0 MB/s
--------------------------------------------------------------------
脚本似乎无法“看到”数据目录中的任何文件。我在 cmd 中尝试了相同的前缀python,它给出了相同的结果。我该如何解决这个问题?
供您参考,我将undaq.py文件的内容粘贴到这里:
#!C:\Users\durraniu\Anaconda\python.exe
# EASY-INSTALL-SCRIPT: 'undaqtools==0.2.3','undaq.py'
__requires__ = 'undaqtools==0.2.3'
__import__('pkg_resources').run_script('undaqtools==0.2.3', 'undaq.py')
请注意,我安装了 undaqtools 版本 0.2.3。
更新 2
我也尝试过在 Ipython 中进行以下操作:
%run -G C:/Users/durraniu/Anaconda/Scripts/undaq.py -r -d *
【问题讨论】:
标签: python windows ipython argparse