您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在Jython中安装各种Python库?

如何在Jython中安装各种Python库?

某些python模块(如)lxml在C中具有必需的组件。它们在Jython中不起作用。

大多数Python软件包都可以正常运行,你可以使用与cpython相同的工具来安装它们。在Jython Book的附录A中对此进行了描述:

要获得setuptools,请从http://peak.telecommunity.com/dist/ez_setup.py下载ez_setup.py 。然后,转到你保留下载文件的目录并执行:

$ jython ez_setup.py

[easy_install脚本将被安装]安装到Jython安装的bin目录中(/home/lsoto/jython2.5.0/bin在上面的示例中)。如果你经常使用Jython,则最好将此目录添加到PATH环境变量之前,这样就不必每次都要使用easy_install或其他安装到此目录的脚本时都键入整个路径。

在Jython中安装setuptools之后,我自己进行了测试,正确安装了pip:

$ sudo /usr/bin/jython2.5.2b1/bin/easy_install pip
Searching for pip
[...]
Installing pip-2.5 script to /usr/bin/jython2.5.2b1/bin
Installing pip script to /usr/bin/jython2.5.2b1/bin

Installed /usr/bin/jython2.5.2b1/Lib/site-packages/pip-1.0.2-py2.5.egg
Processing dependencies for pip
Finished processing dependencies for pip

$ sudo /usr/bin/jython2.5.2b1/bin/pip install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    Installing collected packages: bottle
  Running setup.py install for bottle
Successfully installed bottle
Cleaning up...

$ jython
Jython 2.5.2b1 (Release_2_5_2beta1:7075, Jun 28 2010, 07:44:20) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_26
Type "help", "copyright", "credits" or "license" for more information.
>>> import bottle
>>> bottle
<module 'bottle' from '/usr/bin/jython2.5.2b1/Lib/site-packages/bottle$py.class'>
>>>
python 2022/1/1 18:22:33 有235人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶