来自官方网络x Version 1.9 notes and API changes:
为Jython 2.7 [...]添加了基本支持,但它们仍然没有得到官方支持。
如何在Jython上安装networkx?
我尝试了什么:
sudo /opt/jython2.7.0/bin/pip install networkx
下载了文件networkx-1.9.1-py2.py3-none-any.whl
,但在某些时候出错:
Exception:
Traceback (most recent call last):
File "/opt/jython2.7.0/Lib/site-packages/pip/basecommand.py", line 133, in main
status = self.run(options, args)
File "/opt/jython2.7.0/Lib/site-packages/pip/commands/install.py", line 325, in run
requirement_set.install(
File "/opt/jython2.7.0/Lib/site-packages/pip/commands/install.py", line 325, in run
requirement_set.install(
File "/opt/jython2.7.0/Lib/site-packages/pip/req/req_set.py", line 633, in install
requirement.install(
File "/opt/jython2.7.0/Lib/site-packages/pip/req/req_install.py", line 719, in install
self.move_wheel_files(self.source_dir, root=root)
File "/opt/jython2.7.0/Lib/site-packages/pip/req/req_install.py", line 990, in move_wheel_files
move_wheel_files(
File "/opt/jython2.7.0/Lib/site-packages/pip/wheel.py", line 154, in move_wheel_files
compileall.compile_dir(source, force=True, quiet=True)
File "/opt/jython2.7.0/Lib/compileall.py", line 56, in compile_dir
if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
File "/opt/jython2.7.0/Lib/compileall.py", line 56, in compile_dir
if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
File "/opt/jython2.7.0/Lib/compileall.py", line 50, in compile_dir
if not compile_file(fullname, ddir, force, rx, quiet):
File "/opt/jython2.7.0/Lib/compileall.py", line 99, in compile_file
ok = py_compile.compile(fullname, None, dfile, True)
File "/opt/jython2.7.0/Lib/compileall.py", line 99, in compile_file
ok = py_compile.compile(fullname, None, dfile, True)
File "/opt/jython2.7.0/Lib/py_compile.py", line 99, in compile
_py_compile.compile(file, cfile, dfile)
File "/opt/jython2.7.0/Lib/py_compile.py", line 99, in compile
_py_compile.compile(file, cfile, dfile)
RuntimeException: java.lang.RuntimeException: Method code too large!
我在_py_compile.compile(file, cfile, dfile)
函数之前添加了以下print语句:
print "file: %s" % file
print "cfile: %s" % cfile
print "dfile: %s" % dfile
给了我:
file: /tmp/pip_build_vagrant/networkx/networkx/generators/atlas.py
cfile: None
dfile: None
有没有人设法在Jython2.7.0上安装networkx 1.9?
答案 0 :(得分:4)
以下是如何在Jython中安装networkx:
networkx/generators/atlas.py
(这是Jython无法解析的文件。无论如何它在Jython中都不起作用,所以只需删除它。)networkx/readwrite/gml.py
中的,删除了lib2to3的所有提及(由于Jython中的当前错误,lib2to3不可用):
在75左右的行上,更改:
rtp_fix_unicode = RefactoringTool(['lib2to3.fixes.fix_unicode'],
{'print_function': True})
为:
rtp_fix_unicode = None
返回源文件夹,然后运行:
jython/pip install .
或者,如果你没有jython的pip:
jython setup.py install
它应该成功安装,你现在应该能够在Jython中导入networkx。