0
在参考hooking into PIP from Jython,它看起来像,可能的话,PIP附带的Jython:如何通过Jython导入PIP包?
如何,具体而言,来自Jython本身,是PIP invok ED?既要安装软件包,更重要的是要导入该软件包以供参考?
我没有看到用Jython编写的具体代码示例。
在参考hooking into PIP from Jython,它看起来像,可能的话,PIP附带的Jython:如何通过Jython导入PIP包?
如何,具体而言,来自Jython本身,是PIP invok ED?既要安装软件包,更重要的是要导入该软件包以供参考?
我没有看到用Jython编写的具体代码示例。
一旦Jython的2.7安装到~/
则:
[email protected]:~$
[email protected]:~$ jython --version
Jython 2.7.0
[email protected]:~$
[email protected]:~$ pip --version
pip 1.6.dev1 from /home/thufir/jython/Lib/site-packages (python 2.7)
[email protected]:~$
[email protected]:~$ pip freeze
[email protected]:~$
[email protected]:~$ pip install virtualenv
Downloading/unpacking virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB): 1.8MB
downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
[email protected]:~$
[email protected]:~$ mkdir nfl
[email protected]:~$
[email protected]:~$ cd nfl
[email protected]:~/nfl$
[email protected]:~/nfl$ jython -m virtualenv jve
Cannot find file /home/thufir/jython/Include (bad symlink)
New jython executable in /home/thufir/nfl/jve/bin/jython
Installing setuptools, pip, wheel...done.
[email protected]:~/nfl$
[email protected]:~/nfl$ . jve/bin/activate
(jve) [email protected]:~/nfl$
(jve) [email protected]:~/nfl$ pip install nflgame
Collecting 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 (Subject
Name Indication) extension to TLS is not available on this platform. This
may cause the server to present an incorrect TLS certificate, which can
cause validation failures. You can upgrade to a newer version of Python to
solve this. For more information, see
https://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. This
prevents urllib3 from configuring SSL appropriately and may cause certain
SSL connections to fail. You can upgrade to a newer version of Python to
solve this. For more information, see
https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
warnings.warn(
Downloading nflgame-1.2.20.tar.gz (34.0MB)
100%
|████████████████████████████████| 34.0MB 11kB/s
Collecting pytz (from nflgame)
Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
100%
|████████████████████████████████| 491kB 158kB/s
Collecting httplib2 (from nflgame)
Downloading httplib2-0.10.3.tar.gz (204kB)
100%
|████████████████████████████████| 204kB 136kB/s
Collecting beautifulsoup4 (from nflgame)
Downloading beautifulsoup4-4.5.3-py2-none-any.whl (85kB)
100%
|████████████████████████████████| 92kB 147kB/s
Building 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/749651f7925b231103f5316cacca82a487810c22d30f011c0c
Successfully built nflgame httplib2
Installing collected packages: pytz, httplib2, beautifulsoup4, nflgame
Successfully installed beautifulsoup4-4.5.3 httplib2-0.10.3 nflgame-1.2.20
pytz-2016.10
(jve) [email protected]:~/nfl$
(jve) [email protected]:~/nfl$ pip freeze
appdirs==1.4.0
beautifulsoup4==4.5.3
httplib2==0.10.3
nflgame==1.2.20
packaging==16.8
pyparsing==2.1.10
pytz==2016.10
six==1.10.0
(jve) [email protected]:~/nfl$
然后:
[email protected]:~/nfl$
[email protected]:~/nfl$ . jve/bin/activate
(jve) [email protected]:~/nfl$
(jve) [email protected]:~/nfl$ jython sample.py
L.McCoy 31 carries for 184 yards and 1 TDs
T.Pryor 13 carries for 112 yards and 0 TDs
S.Vereen 14 carries for 101 yards and 0 TDs
A.Peterson 18 carries for 93 yards and 2 TDs
R.Bush 21 carries for 90 yards and 0 TDs
(jve) [email protected]:~/nfl$
(jve) [email protected]:~/nfl$ cat sample.py
import nflgame
games = 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) [email protected]:~/nfl$
虽然它不是严格地需要使用虚拟ENV。