jamesturk/scrapelib

AttributeError: 'module' object has no attribute 'Scraper'

Closed this issue · 18 comments

Hello,

I've just used pip install requests and pip install scrapelib in a new virtualenv, with Python 3.4.

I got this error:

Traceback (most recent call last):
File "C:/Users/natalie/Documents/Encore-in-Google/scrapelib.py", line 1, in
import scrapelib
File "C:/Users/natalie/Documents/Encore-in-Google\scrapelib.py", line 2, in
s = scrapelib.Scraper(requests_per_minute=10)
AttributeError: 'module' object has no attribute 'Scraper'

Not sure what I'm doing wrong? I'm using equests 2.3.0 and Python 3.4 so I think both are compatible with scrapelib? I just copied the example usage at https://github.com/sunlightlabs/scrapelib

I've not used virtualenv before so I'm wondering if that's the problem though both requests and scraplib said they'd installed.

Thanks!

Are you working from within your virtualenv? I'm not sure how virtualenv works on windows, but you should have run an activate step?

When you import scrapelib what does scrapelib.version print as?

Ah... i hadn't yesterday. Since then I've

  • uninstalled scrapelib globally and from the project virtualenv
  • reinstalled scrapelib in the virtualenv

At /env/Scripts I can see:

  • scrapeshell
  • scrapeshell.exe.manifest
  • scrapeshell-script

When I check which python I get:
$ which python
/cygdrive/c/Users/natalie/Documents/Encore-in-Google/env/Scripts/python
(env)

But when I check which scrapelib I get:
$ which scrapelib
which: no scrapelib in (/cygdrive/c/Users/natalie/Documents/Encore-in-Google/env/Scripts:/usr/local/bin:/usr/bin:/cygdrive/c/Python34:/cygdrive/c/Python34/Scripts:/cygdrive/c/Program Files/Broadcom/Broadcom 802.11 Network Adapter/Driver:/cygdrive/c/Program Files (x86)/AMD APP/bin/x86_64:/cygdrive/c/Program Files (x86)/AMD APP/bin/x86:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/Program Files/Lenovo/Bluetooth Software:/cygdrive/c/Program Files/Lenovo/Bluetooth Software/syswow64:/cygdrive/c/Program Files (x86)/nodejs:/cygdrive/c/Users/natalie/AppData/Roaming/npm)
(env)

In IDLE when I run:
import scrapelib
print (scrapelib.version)

I get:
Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 1, in
import scrapelib
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 3, in
print (scrapelib.version)
AttributeError: 'module' object has no attribute 'version'

I'm not why I can see some scrapelib (scrapeshell) files in env/Scripts, but cannot use scrapelib.

Thanks,

can you try printing scrapelib.__version__ with the double underscores

On Wed, Jun 25, 2014 at 3:41 PM, pollecuttn notifications@github.com
wrote:

Ah... i hadn't yesterday. Since then I've

  • uninstalled scrapelib globally and from the project virtualenv
  • reinstalled scrapelib in the virtualenv

At /env/Scripts I can see:

  • scrapeshell
  • scrapeshell.exe.manifest
  • scrapeshell-script

When I check which python I get:
$ which python
/cygdrive/c/Users/natalie/Documents/Encore-in-Google/env/Scripts/python
(env)

But when I check which scrapelib I get:
$ which scrapelib
which: no scrapelib in
(/cygdrive/c/Users/natalie/Documents/Encore-in-Google/env/Scripts:/usr/local/bin:/usr/bin:/cygdrive/c/Python34:/cygdrive/c/Python34/Scripts:/cygdrive/c/Program
Files/Broadcom/Broadcom 802.11 Network Adapter/Driver:/cygdrive/c/Program
Files (x86)/AMD APP/bin/x86_64:/cygdrive/c/Program Files (x86)/AMD
APP/bin/x86:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program
Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/Program
Files/Lenovo/Bluetooth Software:/cygdrive/c/Program Files/Lenovo/Bluetooth
Software/syswow64:/cygdrive/c/Program Files
(x86)/nodejs:/cygdrive/c/Users/natalie/AppData/Roaming/npm)
(env)

In IDLE when I run:
import scrapelib
print (scrapelib.version)

I get:

Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 1,
in
import scrapelib
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 3,
in
print (scrapelib.version)
AttributeError: 'module' object has no attribute 'version'

I'm not why I can see some scrapelib (scrapeshell) files in env/Scripts,
but cannot use scrapelib.

Thanks,


Reply to this email directly or view it on GitHub
#19 (comment)
.

Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 1, in
import scrapelib
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 3, in
print (scrapelib.version)
AttributeError: 'module' object has no attribute 'version'

Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 1, in
import scrapelib
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 3, in
print (scrapelib.version)
AttributeError: 'module' object has no attribute 'version'

very strange- i'd recommend uninstalling & reinstalling scrapelib. are other python libraries working in your environment? is requests?

It doesn't come out in the comment formatting, but I do have the double underscores...

can you rename your file something other than scrapelib? that is likely the culprit (thanks @paultag!)

I uninstalled and reinstalled scrapelib before I commented today.

I can use requests but when I do which requests I get a similar message to the one for scrapelib, whether i have my virtualenv activated or not. I don't know how that's possible.

import requests
r = requests.get('http://google.com')
print (r.status_code)

gives:
200

Have you tried renaming your script scrapelib.py to something else, perhaps
scrapetest.py -- the issue is probably that it is trying to import itself

On Wed, Jun 25, 2014 at 6:11 PM, pollecuttn notifications@github.com
wrote:

I uninstalled and reinstalled scrapelib before I commented today.

I can use requests but when I do which requests I get a similar message to
the one for scrapelib, whether i have my virtualenv activated or not. I
don't know how that's possible.

import requests
r = requests.get('http://google.com')
print (r.status_code)

gives:
200


Reply to this email directly or view it on GitHub
#19 (comment)
.

File renamed scraplib-test.py:
Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib-test.py", line 1, in
import scrapelib
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 3, in
print (scrapelib.version)
AttributeError: 'module' object has no attribute 'version'

You still have a scrapelib.py in that directory, try removing it.

On Wed, Jun 25, 2014 at 6:14 PM, pollecuttn notifications@github.com
wrote:

File renamed scraplib-test.py:

Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib-test.py", line
1, in
import scrapelib

File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib.py", line 3,
in
print (scrapelib.version)
AttributeError: 'module' object has no attribute 'version'


Reply to this email directly or view it on GitHub
#19 (comment)
.

Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib-test.py", line 1, in
import scrapelib
ImportError: No module named 'scrapelib'

At least it's a different message...

So is it telling me I don't have scrapelib? I just tried uninstalling and reinstalling scrapelib again, in my virtualenv, and I'm still getting the same ImportError: No module named 'scrapelib'.

I can still see these in env/Scripts:
scrapeshell
scrapeshell.exe.manifest
scrapeshell-script
(but nothing about scrapelib)

Scrapelib would not appear in env/Scripts, it is a Python module, not a
script.

Are you sure your virtualenv is activated? If you've installed it you
would be able to import it. Does "import requests" still work?

On Wed, Jun 25, 2014 at 6:22 PM, pollecuttn notifications@github.com
wrote:

Traceback (most recent call last):
File "C:\Users\natalie\Documents\Encore-in-Google\scrapelib-test.py", line
1, in
import scrapelib
ImportError: No module named 'scrapelib'

At least it's a different message...

So is it telling me I don't have scrapelib? I just tried uninstalling
and reinstalling scrapelib again, in my virtualenv, and I'm still getting
the same ImportError: No module named 'scrapelib'.

I can still see these in env/Scripts:
scrapeshell
scrapeshell.exe.manifest
scrapeshell-script
(but nothing about scrapelib)


Reply to this email directly or view it on GitHub
#19 (comment)
.

I've been working from http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/ That says pip is in will be in env/bin/pip. I don't have a /bin/ dir, but pip is in env/Scripts so I was using that instead (as a best guess).

I've just had a look in other directories and there is a scrapelib in C:\Users\natalie\Documents\Encore-in-Google\env\Lib\site-packages. Does that sound good? And if so, how do I import scrapelib from there?

I can't see a /bin/ dir anywhere in this project.

import requests still works (still getting a 200 response from http://google.com/)

Sorry- I'm really not qualified to give advice on a Windows Python
environment though, not sure I'll be able to help with this as it doesn't
seem like a scrapelib issue.

I can say that scrapelib being in site-packages is a good thing, assuming
the env is activated, my guess right now is that it isn't activated (the
fact that there isn't an env/bin is concerning as that is where the python
binary should be), but I can't confirm.

On Wed, Jun 25, 2014 at 6:30 PM, pollecuttn notifications@github.com
wrote:

I've been working from
http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
That says pip is in will be in env/bin/pip. I don't have a /bin/ dir, but
pip is in env/Scripts so I was using that instead (as a best guess).

I've just had a look in other directories and there is a scrapelib in
C:\Users\natalie\Documents\Encore-in-Google\env\Lib\site-packages. Does
that sound good? And if so, how do I import scrapelib from there?

I can't see a /bin/ dir anywhere in this project.


Reply to this email directly or view it on GitHub
#19 (comment)
.

Okay, that's fair enough. At least it looks like I've got scrapelib. Thanks a lot for all your help! I'll try to figure out the env/bin problem.