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

nfldb Mac installation #215

Open
cminton opened this issue Dec 3, 2016 · 33 comments
Open

nfldb Mac installation #215

cminton opened this issue Dec 3, 2016 · 33 comments

Comments

@cminton
Copy link

cminton commented Dec 3, 2016

Has anyone installed nfldb on the mac? I have installed postgres and pgAdmin. I am at the point where I create the actual postgresql db. The following command is not recognized:

systemd-tmpfiles --create postgresql.conf

@BurntSushi
Copy link
Owner

BurntSushi commented Dec 3, 2016 via email

@cminton
Copy link
Author

cminton commented Dec 3, 2016

Thanks Andrew. I am trying to set up nfldb, so I can move to it. I am excellent at application development, but very out of touch with systems, so not so good at this type of set up. Does anyone know what steps I take from this point to be able to use nfldb on a Mac?

@BurntSushi
Copy link
Owner

BurntSushi commented Dec 3, 2016 via email

@AndrewRook
Copy link

@cminton I wrote up the steps I had to go through to get nfldb working on my Mac here. It's mostly written so I wouldn't forget how to do it myself, but it might have some useful tips.

@cminton
Copy link
Author

cminton commented Dec 3, 2016

@AndrewRook thank you. When I get to

postgres -D /usr/local/var/postgres

It just seems to hang there. Is it waiting for something from me?

@AndrewRook
Copy link

Yeah, that's normal - that command is running the database in the foreground (the pg_ctl -D /usr/local/var/postgres -l logfile start command right below it is to run the db in the background, although I prefer running postgres in the foreground so I can kill it easily).

If you decide you're happy running postgres in the foreground (ctrl-c should kill it if you want to try the background command) you'll need to open up a new terminal window (command+n) or tab (command+t) and continue there.

@cminton
Copy link
Author

cminton commented Dec 3, 2016

I figured it was looping. I should have thought of opening another terminal window. That was dumb of me.

@cminton
Copy link
Author

cminton commented Dec 3, 2016

Any idea what this error is? I am superuser, so do not think it is permissioning...

Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 377, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip/utils/init.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/share'

@cminton
Copy link
Author

cminton commented Dec 3, 2016

I got that error running

pip2 install nfldb

@AndrewRook
Copy link

Looks like this is a security feature in El Cap. The simple answer (as recommended in that SO question) is to use a virtual environment. The SO answer recommends virtualenv which is a perfectly fine choice, but personally I recommend Miniconda, which will make it way easier if you want to either run multiple versions of Python simultaneously or use libraries like numpy or scipy.

@cminton
Copy link
Author

cminton commented Dec 4, 2016

Then I use a virtual environment to continue the installation or every time I use nfldb?

@AndrewRook
Copy link

Both, basically. You'll install nfldb (and any other packages you need) into the virtual environment, and then whenever you want to use nfldb you'll activate the virtual environment and work from there. Personally I use a new virtual environment for every project - that way you never have to worry about dependencies conflicting between projects.

One caveat, however - the nfldb database will be visible across virtual environments, which is actually kind of nice - if you use nfldb in multiple projects you shouldn't have to remake the database for each one.

@Ash-Digital
Copy link

Hey all, getting stuck at this part of this guide:

http:https://nflwin.readthedocs.io/en/stable/nfldb.html

screen shot 2017-08-18 at 9 48 26 pm

@Ash-Digital
Copy link

Ok and then I got to here

screen shot 2017-08-18 at 9 54 13 pm

@cminton
Copy link
Author

cminton commented Aug 19, 2017 via email

@Ash-Digital
Copy link

@cminton can you help me do that? or are there instructions anywhere for how to do that?

@cminton
Copy link
Author

cminton commented Aug 19, 2017 via email

@Ash-Digital
Copy link

@cminton Not sure 100% what the etiquette is so I won't post links but I have a site full of NFL teams, schedule, games played and player profiles I need to populate with standard data such as catches, yards, etc after every game.

What I would also like is targets, red zone targets, yards after contact, aDOT on top of that. Goal is to build a daily fantasy stacking tool and eventually a game center that updates.

@cminton
Copy link
Author

cminton commented Aug 19, 2017 via email

@Ash-Digital
Copy link

@cminton Average Depth of Target for receivers.

Ok thank you. I'll utilize your code and also keep trying to get the DB up and running at the same time.

@cminton
Copy link
Author

cminton commented Aug 20, 2017 via email

@AndrewRook
Copy link

Hey @Arrashg, going back to this comment, is your username "home"? If that's the case, it looks like you may have missed the step directly after starting up postgres for the first time:

$ createdb `whoami`

That will create a database based on your username, which should solve the does not exist error you got.

@Ash-Digital
Copy link

@AndrewRook Thanks a lot. Made a lot of progress and now I am at the final step of which I am confused about regarding "default configuration directory. I moved it to "Application Support" but not sure this is the correct place. I am an OSX newbie. When I added my password and saved the file, I tried the last few instructions but ended up with this:

screen shot 2017-08-20 at 10 11 12 pm

This is the section I am confused about:

screen shot 2017-08-20 at 10 12 02 pm

@donlaur
Copy link

donlaur commented Aug 21, 2017 via email

@Ash-Digital
Copy link

I'm starting to think that nfldb was saved to the wrong folder. When I try and run it, it says no module named nfldb. I'm still unsure of which .config file to save it to. I tried moving it to .config and then to run it and I get the same problem. I have attached images of where I currently tried to add it.

I'm so close thanks to everyone's help.

screen shot 2017-08-21 at 4 06 57 pm

screen shot 2017-08-21 at 4 07 42 pm

@AndrewRook
Copy link

@Arrashg if you're getting an ImportError when you try to import nfldb you probably have problems with how you installed the module itself, beyond just the config file. How did you install nfldb?

@Ash-Digital
Copy link

Ash-Digital commented Aug 22, 2017

@AndrewRook I followed these steps
http:https://nflwin.readthedocs.io/en/stable/nfldb.html
It seemed like that all worked as I'm able to connect to nfldb.

screen shot 2017-08-21 at 9 50 22 pm

I also tried what was suggested and the list of relations show up fine

screen shot 2017-08-21 at 9 52 37 pm

After that, I moved on to these
https://github.com/BurntSushi/nfldb/wiki/Installation#importing-the-nfldb-database

I did not notice any errors during install and did not run into anymore snags until the .config section. I'm open to uninstalling and going back thru the steps again but not sure if that is the best solution.

Something I noticed is the file path it tried to follow when I ran nfldb-update, doesn't exist when I try and follow it in finder. After "Python.framework", there should be Versions/2.7/share/nfldb/ where I can add the .config file.
screen shot 2017-08-21 at 10 15 19 pm
screen shot 2017-08-21 at 10 15 35 pm

@ochawkeye
Copy link
Contributor

ochawkeye commented Aug 22, 2017

None of the steps in the directions on http:https://nflwin.readthedocs.io explicitly has you install the python nfldb library. Looks to me like you've got the Postgres database imported, but not the Python nfldb package installed.

Try pip install nfldb.

@donlaur
Copy link

donlaur commented Aug 22, 2017 via email

@Ash-Digital
Copy link

@ochawkeye Getting close here. Now when I run the command "import nfldb" it says command not found. When I run "nfldb-update" it updates the db!

screen shot 2017-08-25 at 9 00 16 pm

@AndrewRook
Copy link

In order to use the nfldb Python package (which provides the API wrapper around the postgres database) you have to be running python, either as a script (e.g. python script.py) or through the command line interpreter:

$ python
<Python version information, your info may vary>
>>> import nfldb

@Ash-Digital
Copy link

@AndrewRook When I start python and >>> import nfldb, I get an ImportError but nfldb is located here so not sure why that is
/usr/local/lib/python2.7/site-packages/nfldb

screen shot 2017-08-26 at 2 59 58 pm

screen shot 2017-08-26 at 3 02 18 pm

@AndrewRook
Copy link

that probably means that /usr/local/lib/python2.7/site-packages/ isn't on any of the paths that python is searching when it figures out what packages are installed. This can happen for a few reasons, usually because the python installation you're actually using is different than the python installation you think you're using.

You can see what paths your install is looking in by doing the following:

$ python
>>> import sys
>>> print(sys.path)

For more info on how python finds packages see here.

If this does turn out to be the problem you can either monkey around with sys.path (or the PYTHONPATH environment variable) or you can start using Python inside of virtual environments - I recommend conda.

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

6 participants