I have pytube installed, i am getting an error when i run it(I am using python 3.7), the problem seems to be with the pytube itself ,i am using exact code of tutorials for this module.
import pytube
link ='https://www.youtube.com/watch?v=9bZkp7q19f0'
yt = pytube.YouTube(link)
stream = yt.streams.first()
finished = stream.download()
print('Download is complete')
Traceback (most recent call last):
File "C:\automate the boring stuff\youtubetry.py", line 6, in <module>
yt = pytube.YouTube(link)
File "C:\Users\diodi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 88, in __init__
self.prefetch_init()
[Finished in 6.0s with exit code 1]
I had this issue last week. Since I'm on Ubuntu, what worked for me was navigating to:
/home/<username>/anaconda3/lib/python3.6/site-packages/pytube
and adding
r'\bc\s*&&\s*d\.set\([^,]+,.*?\((?P<sig>[a-zA-Z0-9$]+)\(\(0\s*,\s*window.decodeURIComponent'
to the list of patterns in the get_initial_function_name() function in cipher.py. The error was further discussed in this Github thread.
Related
I have the following code:
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=9bZkp7q19f0')
print(yt.title)
And am being thrown the following error
Traceback (most recent call last):
File "C:\Users\tom\Desktop\Desktop\archiver.py", line 4, in <module>
print(yt.title)
File "C:\Users\tom\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 254, in title
return self.player_config_args['title']
KeyError: 'title'
What is going wrong here?
A lot of people having this issue, one suggested thing to try is to make the following changes mentioned in this pull request.
https://github.com/nficano/pytube/pull/435/files.
I'm new with pyshark, and I write a sample code by searching on the tutorial
import pyshark
cap = pyshark.FileCapture("input.cap")
cap_1 = cap[0]
and then it give me an error
/Users/tingyugu/anaconda3/bin/python /Users/tingyugu/PycharmProjects/final/test.py
Traceback (most recent call last):
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 70, in __getitem__
next(self)
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 60, in __next__
packet = self._packet_generator.send(None)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/tingyugu/PycharmProjects/final/test.py", line 5, in <module>
cap_1 = cap[0]
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 73, in __getitem__
raise KeyError('Packet of index %d does not exist in capture' % packet_index)
KeyError: 'Packet of index 0 does not exist in capture'
I know the reason is that there is no packets in the cap, but my friend can read the file by pyshark
I use the python 3.6.0 anaconda and the pyshark is 0.3.7 in anaconda
if you are on jupyter see this issue on PyShark Repo. I had the same problem, seems like pyshark does not go well with jupyter. I'm gonna assume it might have same issues with ipython as well.
there are some pull requests like this one on their repo too as a fix but nothing merged yet.
I am new to jira-python and have run into an issue with using jirashell.
jira-python was installed from documentation given here: http://jira.readthedocs.org/en/latest/
When I try to start jirashell using:
ubuntu#ip-10-0-0-12:~$ jirashell -s https://jira.atlassian.com
I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/jirashell", line 11, in <module> sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/jira/jirashell.py", line 248, in main
jira = JIRA(options=options, basic_auth=basic_auth, oauth=oauth)
File "/usr/local/lib/python2.7/dist-packages/jira/client.py", line 202, in __init__self._create_oauth_session(oauth)
File "/usr/local/lib/python2.7/dist-packages/jira/client.py", line 1871, in _create_oauth_session
oauth['consumer_key'],
KeyError: u'consumer_key'
I have also tried to get to a server using basic auth but that returns the same error. Using curl works fine, but I wanted to see the objects that are getting returned and get help as I develop by python-jira integration.
Thank you for any insight.
I'm trying to get started using speech recognition in python. First I tried PySpeech (https://code.google.com/p/pyspeech/) using this code:
def listen():
while 1:
said = speech.input()
print said
if said == "off":
break
and got the following traceback:
Traceback (most recent call last):
File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 59, in <module> useful.listen()
File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 48, in listen
said = speech.input()
File "C:\Python27\lib\site-packages\speech.py", line 162, in input
listener = listenforanything(response)
File "C:\Python27\lib\site-packages\speech.py", line 193, in listenforanything
return _startlistening(None, callback)
File "C:\Python27\lib\site-packages\speech.py", line 223, in _startlistening
grammar = context.CreateGrammar()
File "C:\Users\REDACTED\AppData\Local\Temp\gen_py\2.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 2298, in CreateGrammar
ret = self._oleobj_.InvokeTypes(14, LCID, 1, (9, 0), ((12, 49),),GrammarId
AttributeError: 'module' object has no attribute 'VARIANT'
Then I tried dragonfly per the suggestion at the top of the GoogleCode page for PySpeech using the following example code commonly found on dragonfly docs:
from dragonfly.all import Grammar, CompoundRule
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print "Voice command spoken."
# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar") # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule()) # Add the command rule to the grammar.
grammar.load() # Load the grammar.
and got this very similar traceback:
Traceback (most recent call last):
File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 14, in <module>
grammar.load() # Load the grammar.
File "C:\Python27\lib\site-packages\dragonfly\grammar\grammar_base.py", line 302, in load
self._engine.load_grammar(self)
File "C:\Python27\lib\site-packages\dragonfly\engines\engine_sapi5.py", line 79, in load_grammar
handle = self._compiler.compile_grammar(grammar, context)
File "C:\Python27\lib\site-packages\dragonfly\engines\compiler_sapi5.py", line 68, in compile_grammar
grammar_handle = context.CreateGrammar()
File "C:\Users\REDACTED\AppData\Local\Temp\gen_py\2.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 2298, in CreateGrammar
ret = self._oleobj_.InvokeTypes(14, LCID, 1, (9, 0), ((12, 49),),GrammarId
AttributeError: 'module' object has no attribute 'VARIANT'
Both modules were installed using PIP and run using python 2.7 interpreter. It seems like a python version issue to me given that the same error is thrown for two different modules implementing the same thing but I'm pretty stuck on how to proceed.
Any help is greatly appreciated and I'm happy to provide more code/info as its requested. Thanks!
EDIT 1: For anyone experiencing a similar problem who happens to stumble across this post, try https://pypi.python.org/pypi/SpeechRecognition/ as an alternative on py2.7. If it runs without error but behaves inconsistently or infinite loops, try modifying the init method of the recognizer class in init.py around line 100. The energy threshold required some tinkering for me (100->300) which is likely due to the specifics of your mic setup. I also increased my quiet duration (0.5->0.7) because it would cut me off sometimes. After these changes it works fairly well for me, returning very accurate text of the input speech in ~2 seconds after capture ends.
I just installed libgmail on CentOS 5, python 2.6 with easy_install. There was a problem, until i installed mechanize manually. After that easy_install said OK and i wrote 1st test program from the sample i googled:
import libgmail
ga = libgmail.GmailAccount("someaccount#gmail.com", "mypassword")
ga.login()
folder = ga.getMessagesByFolder('inbox')
for thread in folder:
print thread.id, len(thread), thread.subject
for msg in thread:
print " ", msg.id, msg.number, msg.subject
print msg.source
I get the following error message:
Traceback (most recent call last):
File "gm.py", line 4, in <module>
ga.login()
File "build/bdist.linux-i686/egg/libgmail.py", line 305, in login
File "build/bdist.linux-i686/egg/libgmail.py", line 340, in _retrievePage
File "build/bdist.linux-i686/egg/mechanize/_request.py", line 31, in __init__
File "build/bdist.linux-i686/egg/mechanize/_rfc3986.py", line 62, in is_clean_uri
TypeError: expected string or buffer
It seems, i get a problem not with my python code, but with libgmail installation. Any clues, anyone?
libgmail is deprecated and has stopped developing, since gmail started offering imap access.
Use imaplib or similar (twisted.mail comes to mind, example code here).