현재 파이썬 비트 토 런트 추적기를 자이 썬 내부에서 실행하려고하는데이 문제가 발생했습니다. 트래커는 내 플랫폼 용으로 컴파일 된 PyCrypto 라이브러리를 사용하여 파이썬 경로에 추가했습니다. 내가 코드를 실행하려고 할 때, 그러나, 나는 다음과 같은 오류 얻을 :자이 썬에서 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
내가 라이브러리가 파이썬 경로에 있는지 확신하기 때문에 명령
import Crypto.Cipher
작품을
from Crypto.Cipher import ARC4
동안
않습니다. 내가 실행 자바 코드는 다음과 같습니다
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을 자바 확장으로 설치하지 않았습니다. 독립 실행 형 lib jar 파일을 생성하고 프로젝트에 추가했습니다. – Arg