pytube.exceptions.RegexMatchError in python - python

I can try to find youtube videos in different formats. using pytube streams filter but it gives an error pytube.exceptions.RegexMatchError.
from pytube import YouTube
url = input('Enter url :')
link = YouTube(url)
print(link.title)
obj = link.streams.filter(progressive="True")
print(obj)
This error given :
Traceback (most recent call last):
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 170, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 279, in get_throttling_function_name
caller="get_throttling_function_name", pattern="multiple"
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 44, in <module>
yt = myVideo.streams.filter(type='mp4')
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 285, in streams
return StreamQuery(self.fmt_streams)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 279, in get_throttling_function_name
caller="get_throttling_function_name", pattern="multiple"
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
I can also reinstall pytube using "pip install git+https://github.com/nficano/pytube.git" and also "pip install pytube". but the error is still now.

you can install :
pip install pytube==11.0.1 or pip install --upgrade pytube
or you can change in pytube/cipher.py :
edit line:r'a\.[A-Z]&&\(b=a\.[sg]et\("n"\)\)&&\(b=([^(]+)\(b\),a\.[sg]et\("n",b\)\)}};'
to
r'a\.C&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\),a\.set\("n",b\)\)}};',
in the def get_throttling_function_name(js: str) -> str: function.

Related

cant uninstall numpy on windows

i just want to uninstall numpy using
pip uninstall numpy
but it gives me the following error
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 160, in exc_logging_wrapper
status = run_func(*args)
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\uninstall.py", line 98, in run
uninstall_pathset = req.uninstall(
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_install.py", line 659, in uninstall
uninstalled_pathset = UninstallPathSet.from_dist(dist)
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_uninstall.py", line 526, in from_dist
for path in uninstallation_paths(dist):
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_uninstall.py", line 45, in unique
for item in fn(*args, **kw):
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_uninstall.py", line 85, in uninstallation_paths
for entry in entries:
File "C:\Users\dmits\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\metadata\base.py", line 472, in <genexpr>
return (str(pathlib.Path(row[0])) for row in csv.reader(text.splitlines()))
_csv.Error: line contains NUL
can anybody help? btw the command is written in terminal

How to fix this error in Pyttsx3: KeyError: 'VoiceAge'

I installed Pyttsx3 with mamba on Mac OS. All was working fine.
Then I upgraded to Mac OS Ventura 13.01 and I get an error on this minimal working example:
import pyttsx3
engine = pyttsx3.init()
engine.getProperty('voices')
The third line throws an error. Any ideas on why I get this error and how to fix it?:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/engine.py", line 146, in getProperty
return self.proxy.getProperty(name)
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/driver.py", line 173, in getProperty
return self._driver.getProperty(name)
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 69, in getProperty
return [self._toVoice(NSSpeechSynthesizer.attributesForVoice_(v))
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 69, in <listcomp>
return [self._toVoice(NSSpeechSynthesizer.attributesForVoice_(v))
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 64, in _toVoice
attr['VoiceAge'])
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/objc/_convenience_mapping.py", line 18, in __getitem__objectForKey_
return container_unwrap(res, KeyError, key)
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/objc/_convenience.py", line 122, in container_unwrap
raise exc_type(*exc_args)
KeyError: 'VoiceAge'

Can't install python module "pywhatkit"

So I was working on a automated whatsapp messenger and I tried to install the module known as "pywhatkit" but I am getting an error everytime.
The error trace is the following:
ERROR: Exception: Traceback (most recent call last): File
"c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\resolvelib\resolvers.py",
line 171, in _merge_into_criterion
crit = self.state.criteria[name] KeyError: 'pymsgbox'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 189, in _main
status = self.run(options, args)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\cli\req_command.py", line 178, in wrapper
return func(self, options, args)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\commands\install.py", line 316, in run
requirement_set = resolver.resolve(
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 121, in resolve
self._result = resolver.resolve(
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 453, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 318, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _merge_into_criterion
crit = Criterion.from_requirement(self._p, requirement, parent)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 82, in from_requirement
if not cands:
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 124, in __bool__
return bool(self._sequence)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in __bool__
return any(self)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 38, in _iter_built
candidate = func()
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 167, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 300, in __init__
super().__init__(
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 144, in __init__
self.dist = self._prepare()
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 226, in _prepare
dist = self._prepare_distribution()
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 311, in _prepare_distribution
return self._factory.preparer.prepare_linked_requirement(
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\operations\prepare.py", line 457, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\operations\prepare.py", line 500, in _prepare_linked_requirement
dist = _get_prepared_distribution(
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\operations\prepare.py", line 66, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\distributions\sdist.py", line 39, in prepare_distribution_metadata
self._setup_isolation(finder)
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\distributions\sdist.py", line 66, in _setup_isolation
self.req.build_env = BuildEnvironment()
File "c:\users\पज\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\build_env.py", line 83, in __init__
fp.write(textwrap.dedent(
File "c:\users\पज\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 148-149: character maps to <undefined>
pip install pywhatkit
If this doesn't work use
pip install pipwin
And then
pipwin install pywhatkit
If it is installed and giving error try
pip install pywhatkit --upgrade
I had the same problem. I used a lot of tricks but finally got my solution. I didn't add my python scripts directory in the path variable. C:\Users\Computer\AppData\Roaming\Python\Python310\Scripts. When I added this path to the path variable. Then pywhatkit was running on my machine. Note: I had recently reset my computer and gave it windows 10 pro!

how to solving error in uploading file via ftp in python

i have this code in python2.7 for upload photos.zip file on the server via ftp.
import ftplib
session = ftplib.FTP('server.address.com','USERNAME','PASSWORD')
file = open('c:\archived\photos.zip','rb') # file to send
session.storbinary('STOR photos.zip', file) # send the file
file.close() # close file and FTP
session.quit()
but i have this error :
raceback (most recent call last):
File "a.py", line 24, in <module>
file = open('c:\archived\photos.zip','rb')
IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\archived\photos.zip'
also I used this solution :
file = open(os.path.join('c:/','archived','photos.zip'),'rb')
but I get this error :
Traceback (most recent call last):
File "s.py", line 28, in <module>
session.storbinary('s.zip', file)
File "C:\Users\0xuser\Anaconda2\lib\ftplib.py", line 479, in storbinary
conn = self.transfercmd(cmd, rest)
File "C:\Users\0xuser\Anaconda2\lib\ftplib.py", line 378, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Users\0xuser\Anaconda2\lib\ftplib.py", line 341, in ntransfercmd
resp = self.sendcmd(cmd)
File "C:\Users\0xuser\Anaconda2\lib\ftplib.py", line 251, in sendcmd
return self.getresp()
File "C:\Users\0xuser\Anaconda2\lib\ftplib.py", line 226, in getresp
raise error_perm, resp
ftplib.error_perm: 500 Unknown command.
Try using forward slashes :
file = open('c:/archived/photos.zip','rb') # file to send

Pip install error

Whenever I try to use pip I receive the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 720, in <module>
class Environment(object):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 723, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 109, in get_supported_platform
plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 221, in _macosx_vers
version = platform.mac_ver()[0]
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform.py", line 804, in mac_ver
info = _mac_ver_xml()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform.py", line 781, in _mac_ver_xml
pl = plistlib.readPlist(fn)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
rootObject = p.parse(pathOrFile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
parser.ParseFile(fileobj)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 418, in handleEndElement
handler()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 452, in end_key
self.currentKey = self.getData()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 436, in getData
data = data.encode("ascii")
LookupError: no codec search functions registered: can't find encoding
trying to run sudo easy_install pip results in the same message. I have previously used pip and received this when trying to install a virtualenv for a project. I can't think of any recent updates or system changes that would have caused this. Has anyone encountered this error message before?

Categories