0

I have the following imports for mainly external modules:

import urllib
from urllib.request import urlopen
from bs4 import BeautifulSoup
from .FrequencySummarizer import FrequencySummarizer

The last line is an attempt to import the FrequencySummarizer class from the FrequencySummarizer.py file in the same folder as the script the imports appear in. When I try and run my script, I get the following error:

ImportError: attempted relative import with no known parent package

What is wrong with my import statement?

ProfK
  • 49,207
  • 121
  • 399
  • 775
  • Question appears to have a suitable answer here: https://stackoverflow.com/questions/2792650/import-error-no-module-name-urllib2 – Batman May 10 '20 at 12:42
  • Does this answer your question? [Import error: No module name urllib2](https://stackoverflow.com/questions/2792650/import-error-no-module-name-urllib2) – Aurélien B May 10 '20 at 17:34

1 Answers1

2

Remove the dot(.) from your last import, you don't need it there. Instead use

from FrequencySummarizer import FrequencySummarizer

Now it'll work fine.

Roy
  • 1,612
  • 2
  • 12
  • 38