小编The*_*igS的帖子

在jython中导入python模块

我在jython下导入scapy时遇到了一些问题.我一直在做java,但python只用了一两天.

重现问题的简单案例是:

$jython

>>> import sys
>>> sys.path
['', '/usr/share/jython/Lib', '/usr/lib/site-python', '__classpath__']
>>> from scapy.all import *
Traceback (innermost last):
File "<console>", line 1, in ?
ImportError: no module named scapy
Run Code Online (Sandbox Code Playgroud)

如果我完成这些完全相同的步骤python,一切正常.我怎么告诉jython使用scapy?如果它有帮助,我正在运行ubuntu 10.04并安装了jython和scapy viaapt-get install

python import jython scapy importerror

11
推荐指数
2
解决办法
2万
查看次数

对象与main()之间的区别和扩展应用程序在scala中

我正在通过ScalaInAction工作(书籍仍然是MEAP,但代码在github上是公开的)现在我正在第2章中查看这个restClient :: https://github.com/nraychaudhuri/scalainaction/blob/master/ chap02/RestClient.scala

首先,我使用scala扩展设置了intelliJ并创建了一个HelloWorld main():

<ALL the imports>

object HelloWorld {
   def main(args: Array[String]) {
     <ALL the rest code from RestClient.scala>
   }
}
Run Code Online (Sandbox Code Playgroud)

编译时出现以下错误:

scala: forward reference extends over defintion of value command
val httppost = new HttpPost(url)
                ^
Run Code Online (Sandbox Code Playgroud)

我可以通过移动以下几行来解决这个问题,直到有关defs 的顺序正确

require( args.size >= 2, "You need at least two arguments to make a get, post, or delete request")

val command = args.head
val params = parseArgs(args)
val url = args.last

command match {
  case "post" …
Run Code Online (Sandbox Code Playgroud)

scala

3
推荐指数
1
解决办法
3426
查看次数

标签 统计

import ×1

importerror ×1

jython ×1

python ×1

scala ×1

scapy ×1