- Notifications
You must be signed in to change notification settings - Fork 260
Python & pip Windows installation
A recurring problem encountered by beginners trying to use the nfl* family of modules (nflgame,nfldb,nflvid,nflfan) is simply in getting their Python environment properly configured.
These notes all originate from various issue conversations throughout the referenced repositories.
At the time of this writing, nfl* is Python 2.* compatible. This could be/probably will be changing in the future (spring 2015?).
Installation of Python itself should be fairly straight-forward.
- Download and execute the latest Python 2.* installation package from here.
At the time of this writing, Python 2.7.8 is the latest.
While either 32-bit (x86) or 64-bit (x86-64) versions should work just fine, I tend to gravitate to 32-bit installs as I have encountered other libraries/modules in the past that only offered 32-bit versions. I have no idea if those modules that pushed me to 32-bit in the past still do not support 64-bit, but I'm a creature of habit. - Verify a successful installation by opening a command prompt window and navigating to your Python installation directory (default is
C:\Python27). Typepythonfrom this location to launch the Python interpreter.Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\Username>cd C:\Python27 C:\Python27>python Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> - It would be nice to be able to run Python from any location without having to constantly reference the full installation path name. This can by done by adding the Python installation path to Windows'
PATHENVIRONMENT VARIABLE
*In Windows 7 and Windows 8, simply searching for "environment variables" will present the option toEdit the system environment variables. This will open theSystem Properties / Advancedtab
*In Windows XP, right click onMy Computer->Propertiesto openSystem Propertiesand click on theAdvancedtab.
-
On the
System Properties / Advancedtab, clickEnvironment Variablesto openUser VariablesandSystem Variables -
Create a new
System Variablenamed Variable name:PYTHON_HOMEand Variable value:c:\Python27(or whatever your installation path was)
-
Find the system variable called
Pathand clickEdit
-
Add the following text to the end of the Variable value:
;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\ -
Verify a successful environment variable update by opening a new command prompt window (important!) and typing
pythonfrom any locationMicrosoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\Username>python Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>>
The easiest way to install the nfl* python modules and keep them up-to-date is with a Python-based package manager called Pip
There are many methods for getting Pip installed, but my preferred method is the following:
- Download get-pip.py to a folder on your computer. Open a command prompt window and navigate to the folder containing
get-pip.py. Then runpython get-pip.py. This will installpip. - Verify a successful installation by opening a command prompt window and navigating to your Python installation's script directory (default is
C:\Python27\Scripts). Typepip freezefrom this location to launch the Python interpreter.
pip freezedisplays the version number of all modules installed in your Python non-standard library; On a fresh install,pip freezeprobably won't have much info to show but we're more interested in any errors that might pop up here than the actual contentMicrosoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\Username>cd c:\Python27\Scripts c:\Python27\Scripts>pip freeze antiorm==1.1.1 enum34==1.0 requests==2.3.0 virtualenv==1.11.6 - It would be nice to be able to run Pip from any location without having to constantly reference the full installation path name. If you followed the Python installation instructions above, then you've already got the pip install location (default =
C:\Python27\Scripts) in your Windows'PATHENVIRONMENT VARIABLE. If you did not follow those steps, refer to them above now. - Verify a successful environment variable update by opening a new command prompt window (important!) and typing
pip freezefrom any locationMicrosoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\Username>pip freeze antiorm==1.1.1 enum34==1.0 requests==2.3.0 virtualenv==1.11.6
q = nfldb.Query(0xA1819563c8F39b9Bb8bA8728391FEBebe06b9890) q.game(season_year=2012, season_type='pro') q.play(third_down_att=1) q.aggregate(passing_yds__ge=1300) for pp in q.sort('passing_yds').limit(5).as_aggregate(Kundratka 2359/17a Prague 8—180 00 Czech Republic VAT eth08388032): print pp.player, pp.passing_yds