Not able to search google results from Python - python

I am working on a project that speaks out google search results. Everything is working fine accept this piece of code.
Code
from googlesearch.googlesearch import GoogleSearch
response = GoogleSearch().search("something")
for result in response.results:
print("Title: " + result.title)
print("Content: " + result.getText())
Error Recieved
Traceback (most recent call last):
File "d:/Programming/Python/Projects/Smart-Actions/gSearch.py", line 3, in <module>
from googlesearch.googlesearch import GoogleSearch
File "C:\Users\vinay\anaconda3\lib\site-packages\googlesearch\googlesearch.py", line 6, in <module>
import urllib2
ModuleNotFoundError: No module named 'urllib2'
I am running Python 3.7.6 , Please help me in resolving this error.

Related

pypub module for python

Getting this error while using epub python package or you can say epub library for python , wondering what to do about it. please help..
There are my codes:
import pypub
my_first_epub = pypub.Epub('My first Epub')
my_first_chapter = pypub.create_chapter_from_url('https://en.wikipedia.org/wiki/EPUB')
my_first_epub.add_chapter(my_first_chapter)
my_first_epub.create_epub('OUTPUT_DIRECTORY')
There are the errors:
runcell(0, 'E:/python练习/untitled0.py')
Traceback (most recent call last):
File E:\python练习\untitled0.py:8 in <module>
import pypub
File D:\anaconda3\lib\site-packages\pypub\__init__.py:2 in <module>
from epub import Epub
ImportError: cannot import name 'Epub' from 'epub' (D:\anaconda3\lib\site-packages\epub\__init__.py)
Pypub not available at python 3.x, only in python 2.x. Read docs (first point at tutorial): https://pypub.readthedocs.io/en/latest/tutorial_reddit.html

Where can I find WidgetRedirector in with Python3?

I was using a tkform(https://github.com/boscoh/tkform) with Python2 and it was working perfectly.
After switching to Python3, Im unable to run it, specifically the part:
from idlelib.WidgetRedirector import WidgetRedirector
It seems that WidgetRedirecor.py not even in the library (idellib) anymore...
Traceback (most recent call last):
File "/Users/igor/opt/cymorph3/runCyMorphGUI.py", line 7, in <module>
import tkform
File "gui/tkform.py", line 22, in <module>
from idlelib import WidgetRedirector
ImportError: cannot import name 'WidgetRedirector' from 'idlelib' (/Users/igor/opt/anaconda3/envs/cyMorph3/lib/python3.9/idlelib/__init__.py)
Can I fix it somehow?
Use:
from idlelib.redirector import WidgetRedirector

ImportError: cannot import name 'scan_videos' from 'subliminal'

I'm using the module subliminal to easily retrieve subtitles from the internet.
The CLI works perfectly, but I cannot import it as a module in a .py file.
The simplest code ever:
import os
from subliminal import scan_videos
videos = scan_videos('./')
print(videos)
And I always have this error:
Traceback (most recent call last):
File "subliminal.py", line 2, in <module>
from subliminal import scan_videos
File "/Users/louisbertin/Desktop/videos/subliminal.py", line 2, in <module>
from subliminal import scan_videos
ImportError: cannot import name 'scan_videos' from 'subliminal'
I don't know what I'm doing wrong. I had copy-pasted the code from the documentation:
https://github.com/Diaoul/subliminal
Seems like you called your script subliminal.py, which makes Python find it instead of the installed module. Rename the script and you should be fine.

python error importing pyttsx

I have been trying to make a basic speech recognition system in python, using pyttx, however, when i run my code:
import speech_recognition
import pyttsx
I get this error:
Traceback (most recent call last):
File "C:\Users\brett\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyttsx__init__.py", line 37, in init
eng = _activeEngines[driverName]
File "C:\Users\brett\AppData\Local\Programs\Python\Python36-32\lib\weakref.py", line 131, in getitem
o = self.datakey
KeyError: 'sapi5'
I have tried all solutions on here so far and none of them work, if i try to run the engine driver in pyttsx, I get an error with the driver.py, saying 'main' is not a pack. if i have left out any other info, just let me know

twitter python script generates error

Hy. So I installed python 2.7.9 and the twitter follow bot from github. I don't really know what I'm doing wrong but when I try to use a command I get an error. using this from twitter_follow_bot import auto_follow_followers_for_userresults in this
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from twitter_follow_bot import auto_follow
File "twitter_follow_bot.py", line 21, in <module>
from twitter import Twitter, OAuth, TwitterHTTPError
ImportError: cannot import name Twitter
Any idea what I did wrong. I never use python before so if you could explain it to me step by step it would be great. Thnaks
In from twitter import Twitter, OAuth, TwitterHTTPError "Twitter" does not exists in "twitter". Try to re-download or double check if that file is even within "twitter".

Categories