LDG
LDG

Reputation: 41

Problem running Python code in Jupyter Notebook: GoodReadsScraper

I would like to start by letting you know that I am a layperson. I only started working with Python a few weeks ago, so I am new to this and am not yet familiar with quite a lot of the necessary terminology. I would be very grateful for your help!

I want to try out Omar Einea's Goodreads Reviews Scraper (https://github.com/OmarEinea/GoodReadsScraper). I followed his instructions and installed beautifulsoup4, langdetect, selenium and lxml using pip. I copy-pasted part of his code from reviews.py to a Jupyter Notebook to test it out and ran the following cell:

from Tools import SafeThread
from bs4 import BeautifulSoup
from langdetect import detect
from Browser import Browser
from Writer import Writer

However, I got the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-4dc46ca353f6> in <module>
----> 1 from Tools import SafeThread
      2 from bs4 import BeautifulSoup
      3 from langdetect import detect
      4 from Browser import Browser
      5 from Writer import Writer

ImportError: cannot import name 'SafeThread' from 'Tools' (unknown location)

I thought that perhaps I had to install tools first, so I ran Python Code:

pip install tools

in the command line, but I received the message that it had already been installed:

C:\Users\Lore>pip install Tools
Requirement already satisfied: Tools in c:\users\xxx\appdata\local\programs\python\python38-32\lib\site-packages (0.1.9)
Requirement already satisfied: pytils in c:\users\xxx\appdata\local\programs\python\python38-32\lib\site-packages (from Tools) (0.3)
Requirement already satisfied: six in c:\users\xxx\appdata\local\programs\python\python38-32\lib\site-packages (from Tools) (1.13.0)
Requirement already satisfied: lxml in c:\users\xxx\appdata\local\programs\python\python38-32\lib\site-packages (from Tools) (4.4.2)

Do you have any ideas on how I might be able to solve this problem?

I also have another question. So far I have only worked in/with jupyter notebooks. Is there a better way/place to write and run my Python scripts/commands?

I tried running the entire code from "Reviews.py", by opening it in IDLE and clicking on "run", but that just gave me this:

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
======= RESTART: C:\Users\xxx\Desktop\GoodReadsScraper-master\Reviews.py ======
>>> 

Thank you in advance for your kind help and understanding!

Upvotes: 0

Views: 207

Answers (1)

Wayne
Wayne

Reputation: 9954

'Tools' being referenced in Review.py is this script called 'Tools' in the repository you reference.

What you installed with pip install tools is something not related to that. You can see it here.

You'd have an easier time if you download all the code in the repository and then try running things while your working directory is set to that directory. In a notebook you can use pwd to print your working directory. You can use %cd to change it.

Upvotes: 1

Related Questions