edsu / etudier

Extract a citation network from Google Scholar
161 stars 27 forks source link

UnboundLocalError: local variable 'article_id' referenced before assignment #4

Closed shawngraham closed 6 years ago

shawngraham commented 6 years ago

Hi Ed,

This old friend is back - I've got version 0.0.4 up, and fed it this:

etudier.py 'https://scholar.google.com/scholar?cites=4956378495941026486&as_sdt=2005&sciodt=0,5&hl=en'

with, after a few pages, this result:

https://scholar.google.com/scholar?cites=13168058302942645446&as_sdt=2005&sciodt=0,5&hl=en
Traceback (most recent call last):
  File "/usr/local/bin/etudier.py", line 266, in <module>
    main(args.url, output=args.output, depth=args.depth, pages=args.pages)
  File "/usr/local/bin/etudier.py", line 20, in main
    for from_pub, to_pub in get_citations(url, depth=depth, pages=pages):
  File "/usr/local/bin/etudier.py", line 91, in get_citations
    pages=pages
  File "/usr/local/bin/etudier.py", line 76, in get_citations
    'id': article_id,
UnboundLocalError: local variable 'article_id' referenced before assignment
shawngraham commented 6 years ago

part of the issue i think is that i keep not pointing it at the correct start page.

For instance, say I want to use etudier on 'Archaeology and the Senses' by Y Hamilakis. I eventually get to the page for the book itself, eg

https://scholar.google.com/scholar?cites=4956378495941026486&as_sdt=2005&sciodt=0,5&hl=en

And to the eye, the page all looks similar as in your example,

https://scholar.google.com/scholar?hl=en&as_sdt=20000005&sciodt=0,21&cites=17950649785549691519&scipsc=

But I'm missing the &scipsc= which maybe doesn't matter, but I also note your example

etudier.py 'https://scholar.google.com/scholar?start=0&hl=en&as_sdt=20000005&sciodt=0,21&cites=17950649785549691519&scipsc='

has a bit of extra in there, eg start=0 which I guess I'll try next... someday, I'll know what i'm doing....

edsu commented 6 years ago

@shawngraham your example worked fine for me. Are you sure you installed v0.0.4?

pip3 install -U etudier

You can verify with:

pip3 list | grep etudier
shawngraham commented 6 years ago

so I'd done this earlier today:

sudo pip3 install etudier --upgrade

and thought I'd updated everything, but when I check pip3 list | grep etudier it seems I'm still in 0.0.1. D'oh. So, I pip3 install -U etudier with the result:

Installing collected packages: etudier
Successfully installed etudier-0.0.4
dhcp-109-32:etudier shawngraham$ pip3 list | grep etudier
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
etudier (0.0.1)

so something ain't right with my system...

ah, but wait:

dhcp-109-32:etudier shawngraham$ pip list | grep etudier
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
etudier (0.0.4)

I'm assuming the difference between pip and pip3 is python 2.7 and python 3.6; 3.6 is my default...

edsu commented 6 years ago

Yeah, it's not uncommon for this kind of thing to happen. I seem to remember you installed without pip the first time?

I would first uninstall:

sudo pip3 uninstall etudier

Now see where it is installed:

which etudier

And forcefully remove it?

Then reinstall:

sudo pip3 install etudier
shawngraham commented 6 years ago
Installing collected packages: etudier
Successfully installed etudier-0.0.4
dhcp-109-32:etudier shawngraham$ which etudier
dhcp-109-32:etudier shawngraham$ pip3 list | grep etudier
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
etudier (0.0.1)
shawngraham commented 6 years ago

ok, I eventually had to delete manually, and though i install with pip3, it's not appearing in my pip3 list; it does appear in pip list. And my original query works, with 0.04.

So, as it so often does, everything comes down to me crossing the streams and really I gotta get into the habit of using virtualenvs.... sorry to have taken up your time with this!

edsu commented 6 years ago

Oh, do you have pip and pip3?

It's no problem at all. I want to hear reports like this...so thank you!