我目前正试图让python bittorrent跟踪器在jython中运行,我遇到了这个问题: 跟踪器使用PyCrypto库,我为我的平台编译并添加到python路径中。当我尝试运行代码,不过,我得到以下错误:Jython中的PyCrypto导入问题
Exception in thread "MainThread" Traceback (most recent call last):
File "./python_dep/BitTorrent-5.2.2/bittorrent-tracker.py", line 21, in <module>
from BitTorrent.track import track
File "./python_dep/BitTorrent-5.2.2/BitTorrent/track.py", line 50, in <module>
from BitTorrent.UI import Size
File "./python_dep/BitTorrent-5.2.2/BitTorrent/UI.py", line 37, in <module>
from BitTorrent.MultiTorrent import UnknownInfohash, TorrentAlreadyInQueue, TorrentAlreadyRunning, TorrentNotRunning
File "./python_dep/BitTorrent-5.2.2/BitTorrent/MultiTorrent.py", line 25, in <module>
from BitTorrent.Torrent import Feedback, Torrent
File "./python_dep/BitTorrent-5.2.2/BitTorrent/Torrent.py", line 32, in <module>
from BitTorrent.ConnectionManager import ConnectionManager
File "./python_dep/BitTorrent-5.2.2/BitTorrent/ConnectionManager.py", line 22, in <module>
from BitTorrent.Connector import Connector
File "./python_dep/BitTorrent-5.2.2/BitTorrent/Connector.py", line 27, in <module>
from Crypto.Cipher import ARC4
ImportError: cannot import name ARC4
Java Result: 1
我敢肯定,该库是在Python路径,因为命令
import Crypto.Cipher
作品,而
from Crypto.Cipher import ARC4
没有。 Java代码我运行是这样的:
package jythTest;
进口org.python.util.PythonInterpreter;
public class Main {
public static void main(String[] args) {
PythonInterpreter pythonInterpreter = new PythonInterpreter();
pythonInterpreter.exec("import sys");
pythonInterpreter.exec("sys.path.append(\"./python_dep/BitTorrent-5.2.2/\")");
pythonInterpreter.exec("sys.path.append(\"./python_dep/Twisted-10.0.0/\")");
pythonInterpreter.exec("sys.path.append(\"./python_dep/Zope-3.4.0/build/lib.linux-i686-2.6\")");
pythonInterpreter.exec("sys.path.append(\"./python_dep\")");
pythonInterpreter.exec("sys.path.append(\"./python_dep/pycrypto-2.0.1/build/lib.linux-i686-2.6\")");
pythonInterpreter.exec("sys.path.append(\"import Crypto.Cipher\")");
//pythonInterpreter.exec("print sys.path");
pythonInterpreter.execfile("./python_dep/BitTorrent-5.2.2/bittorrent-tracker.py");
}
}
在此先感谢任何可以提供任何帮助的人。
有趣的是,我没有将jython安装为java扩展,不过我刚刚生成了独立的lib jar并将其添加到项目 – Arg 2010-06-11 08:38:46