Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Jupyter notebooks #7

Closed
arjunalal opened this issue Oct 2, 2018 · 4 comments
Closed

Compatibility with Jupyter notebooks #7

arjunalal opened this issue Oct 2, 2018 · 4 comments

Comments

@arjunalal
Copy link

I wanted to use this package in a Jupyter notebook to more easily visualize data in-line and increase comprehension of the code. An issue that I ran into was that the module was unable to be imported into Jupyter notebooks when it was working just fine on other local Python environments. I came to a solution that I wanted to share in case anyone was having similar issues.

The issue occurs because the ipython interpreter runs in the same directory that you started the server in. The issue is solved by providing the interpreter with the path to where to module is contained (probably the site-packages folder).

import sys
sys.path.append('C:\Python27\Lib\site-packages')

from nba_api.stats.endpoints import whatever

Doing this allows for full functionality of the package in a Jupyter notebook. I hope this helps someone else!

@arjunalal arjunalal reopened this Oct 2, 2018
@swar
Copy link
Owner

swar commented Oct 3, 2018

So I don't have a lot of experience with Jupyter notebooks, but I believe your issue is related to something different. It looks like the version of python that is running the Jupyter notebook does not contain nba_api. Your solution works, because you're taking it from the python version that has it installed.

import sys
print(sys.version)

Will let you know which Python version you are running. You might be able to quickly fix this issue by using pip3 instead of pip so try running the code below in terminal / command prompt and this might fix having to append the site-packages.

pip3 install nba_api

@arjunalal
Copy link
Author

I am using Python 2.7.15 which is the version that came installed on the corporate laptop I am currently using. Since I don't have admin rights on this machine, I can't update to Python 3 or use pip3.

@swar
Copy link
Owner

swar commented Oct 5, 2018

That makes a lot more sense to me of why you had to go about it this way. Thanks for sharing!

@swar
Copy link
Owner

swar commented Nov 28, 2018

Contributions from @eswan18 will help people with this.
https://github.com/swar/nba_api/tree/master/docs/examples

@swar swar closed this as completed Nov 28, 2018
rsforbes added a commit that referenced this issue Sep 22, 2021
Updated data.py with current player data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants