In the following code, i get bad zip file error.
ctx = mx.gpu(0)
bert = BertEmbedding(ctx=ctx)
The output of the code is
Downloading C:\Users\USER\.mxnet\models\bert_12_768_12_book_corpus_wiki_en_uncased-
75cc780f.zip from https://apache-mxnet.s3-
accelerate.dualstack.amazonaws.com/gluon/models/bert_12_768_12_book_corpus_wiki_en_uncased-
75cc780f.zip...
C:\Users\USER\anaconda3\envs\gpu3\lib\site-packages\mxnet\gluon\utils.py:334: UserWarning:
File C:\Users\USER\.mxnet\models\bert_12_768_12_book_corpus_wiki_en_uncased-75cc780f.zip
exists in file system so the downloaded file is deleted
'File {} exists in file system so the downloaded file is deleted'.format(fname))
---------------------------------------------------------------------------
BadZipFile Traceback (most recent call last)
<ipython-input-4-feea3bcdad25> in <module>
1 ctx = mx.gpu(0)
----> 2 bert = BertEmbedding(ctx=ctx)
~\anaconda3\envs\gpu3\lib\zipfile.py in _RealGetContents(self)
1196 raise BadZipFile("File is not a zip file")
1197 if not endrec:
-> 1198 raise BadZipFile("File is not a zip file")
1199 if self.debug > 1:
1200 print(endrec)
BadZipFile: File is not a zip file
The link of the code i am following is this
Related
I want download video from YouTube with youtube_dl with Colab and save it in google drive. I make a directory with the name of video title and save video in that folder. Then I use this code:
from google.colab import drive
drive.mount('/content/drive', force_remount=True)
URL = "https://www.youtube.com/watch?v=QTPP-iaF7BY&t=1955s"
!pip install youtube_dl
import youtube_dl
with youtube_dl.YoutubeDL({"ignoreerrors": True, "quiet": True}) as ydl:
playlist_dict = ydl.extract_info(URL, download=False)
print('\n', playlist_dict['title'], '\n')
import os
new_folder = playlist_dict['title']
path = f"//content//drive//MyDrive//{new_folder}//".replace("'"," ").replace(".","-").replace(":","-")
os.makedirs(path, exist_ok=True)
print('\n', path, '\n')
%cd {path}
But for the URL that I specified in the above code it get this error:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected
The folder you are executing pip from can no longer be found.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Pillai "Hoeffding's Inequality"
//content//drive//MyDrive//Pillai "Hoeffding's Inequality"//
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-13-dd9eae6c92da>", line 20, in <module>
get_ipython().magic('cd {path}')
File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 2160, in magic
return self.run_line_magic(magic_name, magic_arg_s)
File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 2081, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-84>", line 2, in cd
File "/usr/local/lib/python3.7/dist-packages/IPython/core/magic.py", line 188, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "/usr/local/lib/python3.7/dist-packages/IPython/core/magics/osm.py", line 288, in cd
oldcwd = py3compat.getcwd()
OSError: [Errno 107] Transport endpoint is not connected
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 1823, in showtraceback
stb = value._render_traceback_()
AttributeError: 'OSError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 1132, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 313, in wrapped
return f(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 358, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "/usr/lib/python3.7/inspect.py", line 1502, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
File "/usr/lib/python3.7/inspect.py", line 1460, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
File "/usr/lib/python3.7/inspect.py", line 696, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
File "/usr/lib/python3.7/inspect.py", line 725, in getmodule
file = getabsfile(object, _filename)
File "/usr/lib/python3.7/inspect.py", line 709, in getabsfile
return os.path.normcase(os.path.abspath(_filename))
File "/usr/lib/python3.7/posixpath.py", line 383, in abspath
cwd = os.getcwd()
OSError: [Errno 107] Transport endpoint is not connected
with other URL in YouTube I haven't this problem and it downloads and saves correctly in Google Drive.
EDIT
With changing %cd {path} to os.chdir(path) the problem solved. But
I don't understand why %cd {path} work for some and don't work
for others.
Hi I was creating a simple plain web page with justpy and I got an attribute error.
This was the code:
import justpy as jp
def app():
wp = jp.WebPage()
return wp
jp.justpy(app)
this was the error:
/usr/local/lib/python3.6/dist-packages/justpy
Module directory: /usr/local/lib/python3.6/dist-packages/justpy, Application directory: /home/nsu/Desktop/datavisual
Traceback (most recent call last):
File "Web_App_1.py", line 7, in <module>
jp.justpy(app)
File "/usr/local/lib/python3.6/dist-packages/justpy/justpy.py", line 383, in justpy
uvicorn.run(app, host=host, port=port, log_level=UVICORN_LOGGING_LEVEL)
File "/usr/local/lib/python3.6/dist-packages/uvicorn/main.py", line 461, in run
server.run()
File "/usr/local/lib/python3.6/dist-packages/uvicorn/server.py", line 67, in run
return asyncio.run(self.serve(sockets=sockets))
AttributeError: module 'asyncio' has no attribute 'run'
I tried to replace jp.WebPage() with jp.QuasarPage() but got the same error
pls help.
I need to scrape car type video from YouTube by some tags like this list in Google Colab :
Abarth
AC
Acura
Adam
Adler
AEC
Aero
Aixam
Albion
SO i have tried these two code to find the video tag ( for example tag='Peugeot') in google colab:
!pip install youtube-search-python
from youtubesearchpython import SearchVideos
search = SearchVideos("NoCopyrightSounds", offset = 1, mode = "json", max_results = 20)
print(search.result())
and
!pip install youtube-dl
!echo '' > ford_video_list.txt
!chmod 755 ford_video_list.txt
!youtube-dl --match-title 'ford' --add-metadata --write-thumbnail --list-thumbnails --mark-watched --write-info-json 'ford_video_description_json.txt' --write-description 'ford_video_description.txt' --cookies='Search-youtube-url-file.txt' --ignore-errors --skip-download --get-url -f bestvideo+bestaudio/best --default-search "ytsearch2000:" "Ford Festiva" >> ford_video_list.txt
!echo '*****End of test 1 ******'
But by trying this code it don't showing any result:
import urllib.request
from bs4 import BeautifulSoup
textToSearch = 'python tutorials'
query = urllib.parse.quote(textToSearch)
url = "https://www.youtube.com/results?search_query=" + query
response = urllib.request.urlopen(url)
html = response.read()
soup = BeautifulSoup(html, 'html.parser')
for vid in soup.findAll(attrs={'class':'yt-uix-tile-link'}):
if not vid['href'].startswith("https://googleads.g.doubleclick.net/"):
print('https://www.youtube.com' + vid['href'])
So, i guess the class name is not correct!, and i asked here for debugging it.
Update:
I have made one google colab page (shown below) to test those codes ( also the code of youtube-dl showing this error:
https://colab.research.google.com/drive/1bZQ68gLggTQHCG_5fQQJJTICHA4K3HJ3?usp=sharing
ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests
(caused by <HTTPError 429: 'Too Many Requests'>); please report this
issue on https://yt-dl.org/bug . Make sure you are using the latest
version; see https://yt-dl.org/update on how to update. Be sure to
call youtube-dl with the --verbose flag and include its complete
output.
I understand that error made because:
The google don't like too many request form one IP Address.
So tried to add these tags(--rm-cache-dir --force-ipv4 --verbose) to youtube-dl command as you can see below ( based of these reffrences 1 2 3):
ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 632, in _request_webpage
return self._downloader.urlopen(url_or_request)
File "/usr/local/lib/python3.6/dist-packages/youtube_dl/YoutubeDL.py", line 2238, in urlopen
return self._opener.open(req, timeout=self._socket_timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 564, in error
result = self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 756, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
Thanks.
It has been working by changing the '"ytsearch2000:" "Ford Festiva"` :
to ' "ytsearch50":"Ford Festiva" as you can see below:
!pip install youtube-dl
# !youtube-dl --default-search gvsearch5:how to develop for android --no-playlist --write-info-json --write-annotation --write-thumbnail --write-sub --skip-download
!youtube-dl --match-title 'ford' "ytsearch50":"Ford Festiva"+"peugeot 405" --write-info-json --write-annotation --write-thumbnail --write-sub -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4'
and the problem was because of : and " location mistaking!
the entire code for scraping the video of some car type video from google could be seen here:
https://colab.research.google.com/github/CAR-Driving/yoloOnGoogleColab/blob/master/database_creating/Yoututbe_scraping_by_colab.ipynb
Currently, I'm making a program using python 3.6, and I've been trying to make a sound effect occur after pressing a button. I found something from a different question asked, found here. Down below is my code.
from tkinter import *
window = Tk()
c = Canvas(window, height=100, width=100, bg='blue')
c.pack()
with open('Users/lenonvo/AppData/Local/Programs/Python/Python 3.6/Python 3
Files/Python [3.6.3]/Sounds/Blook Game/Attack.wav','rb') as f:
data = base64.b64encode(f.read())
def playSound():
sound = winsound.PlaySound(base64.b64decode(data), winsound.SND_MEMORY)
def sound(event):
global sound
if event.keysym == 'Up':
playSound()
c.pack('<Key>', sound)
Then I got this error message:
RESTART: C:\Users\lenonvo\AppData\Local\Programs\Python\Python36\Python 3
Files\Python 3.6.3\Test2.py
Traceback (most recent call last):
File "C:\Users\lenonvo\AppData\Local\Programs\Python\Python36\Python 3
Files\Python 3.6.3\Test2.py", line 7, in <module>
with open('Users/lenonvo/AppData/Local/Programs/Python/Python 3.6/Python
3 Files/Python [3.6.3]/Sounds/Blook Game/Attack.wav','rb') as f:
FileNotFoundError: [Errno 2] No such file or directory:
'Users/lenonvo/AppData/Local/Programs/Python/Python 3.6/Python 3
Files/Python [3.6.3]/Sounds/Blook Game/Attack.wav'
Any suggestions?
Also, I am not an advanced python coder, so if your answer could be simplistic, it would be very much appreciated. =]
Now one problem is fixed, thanks to Patrick Artner, but now this error message comes up:
data = base64.b64decode(f.read())
NameError: name 'base64' is not defined
This:
with open('Users/lenonvo/AppData/Local/Programs/Python/Python 3.6/Python 3 Files/Python [3.6.3]/Sounds/Blook Game/Attack.wav','rb') as f:
is a relative path to where your prog runs.
Use
with open('C:/Users/lenonvo/AppData/Local/Programs/Python/Python 3.6/Python 3 Files/Python [3.6.3]/Sounds/Blook Game/Attack.wav','rb') as f:
^^^^
When running the PySide Diagram Scene example (circa 2010), I get the error below. Is there a more current example of a basic diagram editor available?
C:\Python34\python.exe C:/Users/dle/Documents/Programming/Python/diagramscene.py
Traceback (most recent call last):
File "C:/Users/dle/Documents/Programming/Python/diagramscene.py", line 11, in <module>
import diagramscene_rc
File "C:\Users\dle\Documents\Programming\Python\diagramscene_rc.py", line 404, in <module>
qInitResources()
File "C:\Users\dle\Documents\Programming\Python\diagramscene_rc.py", line 399, in qInitResources
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
TypeError: 'qRegisterResourceData' called with wrong argument types:
qRegisterResourceData(int, str, str, str)
Supported signatures:
qRegisterResourceData(int, unicode, unicode, unicode)
The problem is that the file diagramscene_rc.py has been generated for python2, to solve it you must recompile that file for it opens a terminal in the folder and executes the following command:
pyside-rcc diagramscene.qrc -o diagramscene_rc.py -py3
Or, place the letter b before assigning the variable as shown below:
qt_resource_data = "\
\x00\x00\x01\x12\
...
qt_resource_name = "\
\x00\x06\
...
qt_resource_struct = "\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
....
to:
qt_resource_data = b"\
\x00\x00\x01\x12\
...
qt_resource_name = b"\
\x00\x06\
...
qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
....