出现错误“ modulenotfounderror:没有名为“ google”的模块”,但是当尝试通过命令提示符安装时,它说要求已经满足

时间:2018-07-13 18:40:48

标签: python eclipse

很不言自明,试图从Google搜索中做一个小的网页抓取工具,但是当尝试导入时,使用“ var prototype = w.window.Object.getPrototypeOf(input); console.log(prototype); ”我得到了错误:

  

ModuleNotFoundError:没有名为“ google”的模块。

当尝试使用“ infile = 'Vendor List.txt' # Create a generator with differing modes to read the specified lines of the file. def read_gen(infile, mode=0, start=0, end=0, rows=[]): lines = list() with open(infile, 'r') as file: for i, line in enumerate(file): # Set end to correct value if no argument is given. if end == 0: end = len(line) # Mode 0 gives all lines of the file if mode == 0: yield line[start:end] # Mode 1 gives specific lines from the file using the rows keyword # argument. Make sure rows is formatted as [start_row, end_row]. # rows list should only ever be length 2. elif mode == 1: if rows: # Create a list for indices between specified rows. for element in range(rows[0], rows[1]): lines += [element] # Return the current line if the index falls between the # specified rows. if i in lines: yield line[start:end] class GetAddress: def __init__(self): # Allow access to infile for use in set_addresses(). global infile self.address_indices = list() self.phone_indices = list() self.addresses = list() self.count = 0 def get(self, i, line): # Search for appropriate substrings and set indices accordingly. if 'Address:' in line[18:26]: self.address_indices += [i] if 'Phone:' in line[18:24]: self.phone_indices += [i] # Add address to list if both necessary indices have been collected. if i in self.phone_indices: self.set_addresses() def set_addresses(self): self.address = list() start = self.address_indices[self.count] end = self.phone_indices[self.count] # Create a generator that only yields substrings for rows between given # indices. self.generator = read_gen( infile, mode=1, start=40, end=91, rows=[start, end]) # Collect each line of the address from the generator and remove # unnecessary spaces. for element in range(start, end): self.address += [next(self.generator).strip()] # This document has a header on each page and a portion of that is # collected in the address substring. Search for the header substring # and remove the corresponding elements from self.address. if len(self.address) > 3 and not self.address[-1]: self.address = self.address[:self.address.index('header text')] self.addresses += [self.address] self.count += 1 info = GetAddress() for i, line in enumerate(read_gen(infile)): info.get(i, line) ”从命令提示符再次安装google时,出现错误消息: 已经满足要求:from google import search中的google 已满足要求:pip install google中的c:\users\dsimard\python\lib\site-packages (2.0.1)

我正在Eclipse中编写该程序。

1 个答案:

答案 0 :(得分:0)

尝试from googlesearch import search