如何在Jython中安装各种Python库? Jython easy_install错误 如何使用jython setup.py安装?具体如何从Jython本身调用PIP?既要安装软件包,更重要的是要导入该软件包以供参考?我没有看到用Jython编写的特定代码示例. 解决方案将Jython 2.7 安装到~/之后,然后:thufir@doge:~$thufir@doge:~$ jython --versionJython 2.7.0thufir@doge:~$thufir@doge:~$ pip --versionpip 1.6.dev1 from /home/thufir/jython/Lib/site-packages (python 2.7)thufir@doge:~$thufir@doge:~$ pip freezethufir@doge:~$thufir@doge:~$ pip install virtualenvDownloading/unpacking virtualenv Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB): 1.8MBdownloadedInstalling collected packages: virtualenvSuccessfully installed virtualenvCleaning up...thufir@doge:~$thufir@doge:~$ mkdir nflthufir@doge:~$thufir@doge:~$ cd nflthufir@doge:~/nfl$thufir@doge:~/nfl$ jython -m virtualenv jveCannot find file /home/thufir/jython/Include (bad symlink)New jython executable in /home/thufir/nfl/jve/bin/jythonInstalling setuptools, pip, wheel...done.thufir@doge:~/nfl$thufir@doge:~/nfl$ . jve/bin/activate(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ pip install nflgameCollecting nflgame/home/thufir/nfl/jve/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:310:SNIMissingWarning: An HTTPS request has been made, but the SNI (SubjectName Indication) extension to TLS is not available on this platform. Thismay cause the server to present an incorrect TLS certificate, which cancause validation failures. You can upgrade to a newer version of Python tosolve this. For more information, seehttps://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning. warnings.warn(/home/thufir/nfl/jve/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:115:InsecurePlatformWarning: A true SSLContext object is not available. Thisprevents urllib3 from configuring SSL appropriately and may cause certainSSL connections to fail. You can upgrade to a newer version of Python tosolve this. For more information, seehttps://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. warnings.warn( Downloading nflgame-1.2.20.tar.gz (34.0MB) 100%|████████████████████████████████| 34.0MB 11kB/sCollecting pytz (from nflgame) Downloading pytz-2016.10-py2.py3-none-any.whl (483kB) 100%|████████████████████████████████| 491kB 158kB/sCollecting httplib2 (from nflgame) Downloading httplib2-0.10.3.tar.gz (204kB) 100%|████████████████████████████████| 204kB 136kB/sCollecting beautifulsoup4 (from nflgame) Downloading beautifulsoup4-4.5.3-py2-none-any.whl (85kB) 100%|████████████████████████████████| 92kB 147kB/sBuilding wheels for collected packages: nflgame, httplib2 Running setup.py bdist_wheel for nflgame ... done Stored in directory:/home/thufir/.cache/pip/wheels/12/e2/67/97dfa7f48af53140aa18136c8fbf019c455600b00b6cd4f07d Running setup.py bdist_wheel for httplib2 ... done Stored in directory:/home/thufir/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0cSuccessfully built nflgame httplib2Installing collected packages: pytz, httplib2, beautifulsoup4, nflgameSuccessfully installed beautifulsoup4-4.5.3 httplib2-0.10.3 nflgame-1.2.20pytz-2016.10(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ pip freezeappdirs==1.4.0beautifulsoup4==4.5.3httplib2==0.10.3nflgame==1.2.20packaging==16.8pyparsing==2.1.10pytz==2016.10six==1.10.0(jve) thufir@doge:~/nfl$然后:thufir@doge:~/nfl$thufir@doge:~/nfl$ . jve/bin/activate(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ jython sample.pyL.McCoy 31 carries for 184 yards and 1 TDsT.Pryor 13 carries for 112 yards and 0 TDsS.Vereen 14 carries for 101 yards and 0 TDsA.Peterson 18 carries for 93 yards and 2 TDsR.Bush 21 carries for 90 yards and 0 TDs(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ cat sample.pyimport nflgamegames = nflgame.games(2013, week=1)players = nflgame.combine_game_stats(games)for p in players.rushing().sort('rushing_yds').limit(5): msg = '%s %d carries for %d yards and %d TDs' print msg % (p, p.rushing_att, p.rushing_yds, p.rushing_tds)(jve) thufir@doge:~/nfl$尽管并非严格要求使用虚拟环境.In reference to hooking into PIP from Jython, It looks like, possibly, PIP is included with Jython:How can I install various Python libraries in Jython?Jython easy_install errorHow can I use jython setup.py install?How, specifically, from Jython itself, is PIP invoked? Both to install a package and, more importantly, to import that package for reference?I've seen no specific code examples written in Jython. 解决方案 Once Jython 2.7 is installed to ~/ then:thufir@doge:~$thufir@doge:~$ jython --versionJython 2.7.0thufir@doge:~$thufir@doge:~$ pip --versionpip 1.6.dev1 from /home/thufir/jython/Lib/site-packages (python 2.7)thufir@doge:~$thufir@doge:~$ pip freezethufir@doge:~$thufir@doge:~$ pip install virtualenvDownloading/unpacking virtualenv Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB): 1.8MBdownloadedInstalling collected packages: virtualenvSuccessfully installed virtualenvCleaning up...thufir@doge:~$thufir@doge:~$ mkdir nflthufir@doge:~$thufir@doge:~$ cd nflthufir@doge:~/nfl$thufir@doge:~/nfl$ jython -m virtualenv jveCannot find file /home/thufir/jython/Include (bad symlink)New jython executable in /home/thufir/nfl/jve/bin/jythonInstalling setuptools, pip, wheel...done.thufir@doge:~/nfl$thufir@doge:~/nfl$ . jve/bin/activate(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ pip install nflgameCollecting nflgame/home/thufir/nfl/jve/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:310:SNIMissingWarning: An HTTPS request has been made, but the SNI (SubjectName Indication) extension to TLS is not available on this platform. Thismay cause the server to present an incorrect TLS certificate, which cancause validation failures. You can upgrade to a newer version of Python tosolve this. For more information, seehttps://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning. warnings.warn(/home/thufir/nfl/jve/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:115:InsecurePlatformWarning: A true SSLContext object is not available. Thisprevents urllib3 from configuring SSL appropriately and may cause certainSSL connections to fail. You can upgrade to a newer version of Python tosolve this. For more information, seehttps://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. warnings.warn( Downloading nflgame-1.2.20.tar.gz (34.0MB) 100%|████████████████████████████████| 34.0MB 11kB/sCollecting pytz (from nflgame) Downloading pytz-2016.10-py2.py3-none-any.whl (483kB) 100%|████████████████████████████████| 491kB 158kB/sCollecting httplib2 (from nflgame) Downloading httplib2-0.10.3.tar.gz (204kB) 100%|████████████████████████████████| 204kB 136kB/sCollecting beautifulsoup4 (from nflgame) Downloading beautifulsoup4-4.5.3-py2-none-any.whl (85kB) 100%|████████████████████████████████| 92kB 147kB/sBuilding wheels for collected packages: nflgame, httplib2 Running setup.py bdist_wheel for nflgame ... done Stored in directory:/home/thufir/.cache/pip/wheels/12/e2/67/97dfa7f48af53140aa18136c8fbf019c455600b00b6cd4f07d Running setup.py bdist_wheel for httplib2 ... done Stored in directory:/home/thufir/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0cSuccessfully built nflgame httplib2Installing collected packages: pytz, httplib2, beautifulsoup4, nflgameSuccessfully installed beautifulsoup4-4.5.3 httplib2-0.10.3 nflgame-1.2.20pytz-2016.10(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ pip freezeappdirs==1.4.0beautifulsoup4==4.5.3httplib2==0.10.3nflgame==1.2.20packaging==16.8pyparsing==2.1.10pytz==2016.10six==1.10.0(jve) thufir@doge:~/nfl$and then:thufir@doge:~/nfl$thufir@doge:~/nfl$ . jve/bin/activate(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ jython sample.pyL.McCoy 31 carries for 184 yards and 1 TDsT.Pryor 13 carries for 112 yards and 0 TDsS.Vereen 14 carries for 101 yards and 0 TDsA.Peterson 18 carries for 93 yards and 2 TDsR.Bush 21 carries for 90 yards and 0 TDs(jve) thufir@doge:~/nfl$(jve) thufir@doge:~/nfl$ cat sample.pyimport nflgamegames = nflgame.games(2013, week=1)players = nflgame.combine_game_stats(games)for p in players.rushing().sort('rushing_yds').limit(5): msg = '%s %d carries for %d yards and %d TDs' print msg % (p, p.rushing_att, p.rushing_yds, p.rushing_tds)(jve) thufir@doge:~/nfl$although it's not strictly necessary to use the virtual env. 这篇关于如何通过Jython导入PIP包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-22 17:34