在我的Mac上运行Pythonshell时出现TypeError

时间:2016-08-31 11:36:29

标签: javascript python node.js macos typeerror

我使用python shell在node.js中运行python脚本 在我的Windows系统上,一切运行正常 但是在我的Macbook上运行相同的东西会给我带来这个错误:

Error: TypeError: can't multiply sequence by non-int of type 'float'
    at PythonShell.parseError (/Users/johannes/Dropbox/Javascript Projects/DNA Assembler/Algorithmus_Visualisierung/node_modules/python-shell/index.js:183:17)
    at terminateIfNeeded (/Users/johannes/Dropbox/Javascript Projects/DNA Assembler/Algorithmus_Visualisierung/node_modules/python-shell/index.js:98:28)
    at ChildProcess.<anonymous> (/Users/johannes/Dropbox/Javascript Projects/DNA Assembler/Algorithmus_Visualisierung/node_modules/python-shell/index.js:88:9)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    ----- Python Traceback -----
    File "Assembler.py", line 224, in <module>
      reads, n, nUnique, nComplements = readReads(path, verbose = True)
    File "Assembler.py", line 20, in readReads
      reads = random.sample(reads, round(len(reads) * subset))
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 326, in sample
      result = [None] * k

有人知道这里可能出现的问题吗? 我正在寻找一个解决方案,这并不涉及在我的.py中进行大量更改,因为在Windows中一切运行正常。

1 个答案:

答案 0 :(得分:0)

通过将浮点值更改为int来解决。

(虽然知道为什么这只发生在Mac上会很有趣。)