x4nth055 / pythoncode-tutorials Goto Github PK
View Code? Open in Web Editor NEWThe Python Code Tutorials
Home Page: https://www.thepythoncode.com
License: MIT License
The Python Code Tutorials
Home Page: https://www.thepythoncode.com
License: MIT License
I'm enjoying your tutorials and would love to see more of them on Medium or other sites. The watchdog tutorial is a bit more functionality in about 1/3rd the lines of code that I had built, would this be able to be updated with a text based gui?
That way we could have it generate reports, we could prompt the user and it becomes much more interactive, hopefully gets adopted more?
Different function but similar use is this text gui i'm part of updating from morningstar data to pandas and other integrations.
Sorry the links below are not formatted better, my markdown.md skills are a work in progress
[Proposed Menu] from https://github.com/caiobran/mstables
(https://camo.githubusercontent.com/53bb0e06a458f8a73b0c95d9c20b968fbc77cbc32c6f3edf8292d70d68f462ff/68747470733a2f2f692e696d6775722e636f6d2f44315932354c4e2e706e67)
Ex. To get the date published, you run:
However, soup.find("div", {"id": "date"})
now returns:
None
I imagine YouTube has restructured some things in their HTML as soup.find("div")
now returns:
<div class="watch-main-col" id="watch7-content" itemid="" itemscope="" itemtype="http://schema.org/VideoObject">
<link href="https://www.youtube.com/watch?v=jNQXAC9IVRw" itemprop="url"/>
<meta content="Me at the zoo" itemprop="name"/>
<meta content="The first video on YouTube. While you wait for Part 2, listen to this great song: https://www.youtube.com/watch?v=zj82_v2R6ts" itemprop="description"/>
<meta content="False" itemprop="paid"/>
<meta content="UC4QobU6STFB0P71PMvOGN5A" itemprop="channelId"/>
<meta content="jNQXAC9IVRw" itemprop="videoId"/>
<meta content="PT0M19S" itemprop="duration"/>
<meta content="False" itemprop="unlisted"/>
<span itemprop="author" itemscope="" itemtype="http://schema.org/Person">
<link href="http://www.youtube.com/user/jawed" itemprop="url"/>
<link content="jawed" itemprop="name"/>
</span>
<script nonce="MCMF6ByS3CdiigPhN2wRQQ" type="application/ld+json">{"@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [{"@type": "ListItem", "position": 1, "item": {"@id": "http:\/\/www.youtube.com\/user\/jawed", "name": "jawed"}}]}</script>
<link href="https://i.ytimg.com/vi/jNQXAC9IVRw/hqdefault.jpg" itemprop="thumbnailUrl"/>
<span itemprop="thumbnail" itemscope="" itemtype="http://schema.org/ImageObject">
<link href="https://i.ytimg.com/vi/jNQXAC9IVRw/hqdefault.jpg" itemprop="url"/>
<meta content="480" itemprop="width"/>
<meta content="360" itemprop="height"/>
</span>
<link href="https://www.youtube.com/embed/jNQXAC9IVRw" itemprop="embedUrl"/>
<meta content="HTML5 Flash" itemprop="playerType"/>
<meta content="480" itemprop="width"/>
<meta content="360" itemprop="height"/>
<meta content="true" itemprop="isFamilyFriendly"/>
<meta content="AD,AE,AF,AG,AI,AL,AM,AO,AQ,AR,AS,AT,AU,AW,AX,AZ,BA,BB,BD,BE,BF,BG,BH,BI,BJ,BL,BM,BN,BO,BQ,BR,BS,BT,BV,BW,BY,BZ,CA,CC,CD,CF,CG,CH,CI,CK,CL,CM,CN,CO,CR,CU,CV,CW,CX,CY,CZ,DE,DJ,DK,DM,DO,DZ,EC,EE,EG,EH,ER,ES,ET,FI,FJ,FK,FM,FO,FR,GA,GB,GD,GE,GF,GG,GH,GI,GL,GM,GN,GP,GQ,GR,GS,GT,GU,GW,GY,HK,HM,HN,HR,HT,HU,ID,IE,IL,IM,IN,IO,IQ,IR,IS,IT,JE,JM,JO,JP,KE,KG,KH,KI,KM,KN,KP,KR,KW,KY,KZ,LA,LB,LC,LI,LK,LR,LS,LT,LU,LV,LY,MA,MC,MD,ME,MF,MG,MH,MK,ML,MM,MN,MO,MP,MQ,MR,MS,MT,MU,MV,MW,MX,MY,MZ,NA,NC,NE,NF,NG,NI,NL,NO,NP,NR,NU,NZ,OM,PA,PE,PF,PG,PH,PK,PL,PM,PN,PR,PS,PT,PW,PY,QA,RE,RO,RS,RU,RW,SA,SB,SC,SD,SE,SG,SH,SI,SJ,SK,SL,SM,SN,SO,SR,SS,ST,SV,SX,SY,SZ,TC,TD,TF,TG,TH,TJ,TK,TL,TM,TN,TO,TR,TT,TV,TW,TZ,UA,UG,UM,US,UY,UZ,VA,VC,VE,VG,VI,VN,VU,WF,WS,YE,YT,ZA,ZM,ZW" itemprop="regionsAllowed"/>
<meta content="172639384" itemprop="interactionCount"/>
<meta content="2005-04-23" itemprop="datePublished"/>
<meta content="2005-04-23" itemprop="uploadDate"/>
<meta content="Film & Animation" itemprop="genre"/>
</div>
I will fix the lines that are currently broken with a PR....
Hi,
Would you mind please let me know how I can compare yesterday's date with the last_modified date? Cause I want to download only yesterday's file via FTP.
Really appreciate for any suggestion.
Some little changes applied to source code:
import ftplib
import os
from datetime import date
from dateutil import parser
FTP_HOST = "Remote IP"
FTP_USER = "Username"
FTP_PASS = "Password"
# some utility functions that we gonna need
def get_size_format(n, suffix="B"):
# converts bytes to scaled format (e.g KB, MB, etc.)
for unit in ["", "K", "M", "G", "T", "P"]:
if n < 1024:
return f"{n:.2f}{unit}{suffix}"
n /= 1024
def get_datetime_format(date_time):
# convert to datetime object
date_time = datetime.strptime(date_time, "%Y%m%d%H%M%S")
# convert to human readable date time string
return date_time.strftime("%Y/%m/%d %H:%M:%S")
# initialize FTP session
ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)
# force UTF-8 encoding
ftp.encoding = "utf-8"
# print the welcome message
print(ftp.getwelcome())
# change the current working directory to 'pub' folder and 'maps' subfolder
ftp.cwd("RemoteDirectory")
print("*"*50, "NLST", "*"*50)
print("{:20} {:19}".format("File_Name", "last_modified"))
for file_data in ftp.mlsd():
file_name,meta = file_data
# convert it to human readable format (i.e in 'KB', 'MB', etc)
last_modified = get_datetime_format(meta.get("modify"))
try:
ftp.cwd(file_name)
except Exception as e:
ftp.voidcmd("TYPE I")
last_modified = get_datetime_format(meta.get("modify"))
print(f"{file_name:20} {last_modified:19}")
ftp.retrbinary("RETR " + file_name, open(file_name, 'wb').write)
# quit and close the connection
ftp.quit()
Br,
Sara
Seems that the lib is not part of scapy (at least at the time of this post). Should include pywin32 at the requirements file.
When I try to convert image to yolo image with "yolo_opencv.py", I get this error:
Traceback (most recent call last):
File "yolo_opencv.py", line 23, in <module>
net = cv2.dnn.readNetFromDarknet(config_path, weights_path)
cv2.error: OpenCV(3.4.2) /io/opencv/modules/dnn/src/darknet/darknet_io.cpp:684: error: (-215:Assertion failed) ifile.is_open() in function 'ReadDarknetFromWeightsFile'
How can I solve this problem? Thank you.
python3 http_sniffer.py -i wlan0 --show-raw
Operation not permitted
I'm trying to use the using_t5.py script, but i get the above error.
I'm running on WIn10, python 3.8.
Transformers 4.3.3.
Any idea?
Thanks,
Dorit
Exception has occurred: OSError
Unable to open file (unable to open file: name = 'results\2020-05-21_AAPL-huber_loss-adam-LSTM-seq-70-step-1-layers-3-units-256.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
model.load_weights(model_path)
can't detect all faces inside one picture which contain multi people. i am wondering why? the photos faces are clear.
Hi x4nth055,
First, many thanks for your code and your altruism.
I am bioinformatics, not informatics so my knowledge about coding is quite limited. Sorry if the question is stupid.
I using your code to have fun and I try to get all links contained in the website https://es.quora.com/profile/Manolo-Dominguez-Becerra
Here I show you input and output
(base) Monkikys-MBP:Programming monkiky$ python link_extractor.py https://es.quora.com/profile/Manolo-Dominguez-Becerra -m 2
[+] Total Internal links: 0
[+] Total External links: 0
[+] Total URLs: 0
Your code worked with other websites but not with this. Do you know the reason?
Thanks in advances
M
MIMEMultipart
is imported twicelooks like services.py needs some tweaking as it produces continuous errors. I was not able to locate the cause of this one.
p.s.: running on windows
I tried this example:
https://github.com/x4nth055/pythoncode-tutorials/tree/master/web-scraping/extract-and-fill-forms
But failed.
I add res.raise_for_status() after the line calling session.post.
The error is:
Traceback (most recent call last):
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/connectionpool.py", line 964, in prepare_proxy
conn.connect()
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/connection.py", line 416, in connect
self.sock = ssl_wrap_socket(
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/util/ssl.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/util/ssl.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='sometestwebsite', port=443): Max retries exceeded with url: /wp-comments-post.php (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "form_submitter.py", line 68, in
res = session.post(url, data=data)
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/requests/sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/ubuntu/.linuxbrew/Cellar/[email protected]/3.8.5/lib/python3.8/site-packages/requests/adapters.py", line 510, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='sometestwebsite', port=443): Max retries exceeded with url: /wp-comments-post.php (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))
The website for test is Wordpress based.
How can we fix it?
Thanks for your advice in advance.
msg
is not defined in that contextThe error that has occurred is:
X_train.shape: (4181, 100)
X_test.shape: (1394, 100)
y_train.shape: (4181,)
y_test.shape: (1394,)
Train on 4181 samples, validate on 1394 samples
Epoch 1/20
ValueError Traceback (most recent call last)
in
15 batch_size=BATCH_SIZE, epochs=EPOCHS,
16 callbacks=[tensorboard, model_checkpoint],
---> 17 verbose=1)
~\Anaconda3\lib\site-packages\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
1037 initial_epoch=initial_epoch,
1038 steps_per_epoch=steps_per_epoch,
-> 1039 validation_steps=validation_steps)
1040
1041 def evaluate(self, x=None, y=None,
~\Anaconda3\lib\site-packages\keras\engine\training_arrays.py in fit_loop(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)
197 ins_batch[i] = ins_batch[i].toarray()
198
--> 199 outs = f(ins_batch)
200 outs = to_list(outs)
201 for l, o in zip(out_labels, outs):
~\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in call(self, inputs)
2713 return self._legacy_call(inputs)
2714
-> 2715 return self._call(inputs)
2716 else:
2717 if py_any(is_tensor(x) for x in inputs):
~\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in _call(self, inputs)
2653 array_vals.append(
2654 np.asarray(value,
-> 2655 dtype=tf.as_dtype(tensor.dtype).as_numpy_dtype))
2656 if self.feed_dict:
2657 for key in sorted(self.feed_dict.keys()):
~\Anaconda3\lib\site-packages\numpy\core\numeric.py in asarray(a, dtype, order)
536
537 """
--> 538 return array(a, dtype, copy=False, order=order)
539
540
ValueError: could not convert string to float: 'ham,Ok'
Please help me with this.Thanks.
Hello. I need a python interface for yolo. Even my pre-trained model works well with the executable of yolo, any python interface cannot detect any object with the same weights. I used your python interface which is "yolo_opencv.py" and cannot detect any object again. I also tried to use "darknet_images.py" provided from original repository, but result is the same as I mentioned stackoverflow: https://stackoverflow.com/questions/64401460/yolo-darkent-images-py-cannot-detect-the-objects
How can I solve this problem? Thank you!
I want to load a pre-existing audio file into test.py instead of recording. What changes should I make?
Reply asap.
Hi, I don't understand what does it mean that it extract all links from 2 first URLs appeared in github.com, what are these 2 first URLs ?
I want to use the encrypt and decrypt functions in file-encryption, but I'm not sure I can.
What license are they released under? MIT?
Cheers,
Sigge
Getting this error,
Traceback (most recent call last):
File "C:\Python\test12.py", line 34, in
_, msg = imap.fetch(mail, "(RFC822)")
File "C:\Python39\lib\imaplib.py", line 548, in fetch
typ, dat = self._simple_command(name, message_set, message_parts)
File "C:\Python39\lib\imaplib.py", line 1230, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Python39\lib\imaplib.py", line 1055, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: FETCH command error: BAD [b'Could not parse command']
Any ideas?
On the pythoncode tutorial gmail-api:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://gmail.googleapis.com/gmail/v1/users/me/messages/batchModify? returned "Number of ids cannot exceed 1000". Details: "[{'message': 'Number of ids cannot exceed 1000', 'domain': 'global', 'reason': 'invalidArgument'}]">
Specifically, I believe that yt-formatted-string
is no longer populated, breaking everything from "likes" and below.
I expect to see something similar to this as noted here
$ python extract_video_info.py https://www.youtube.com/watch?v=jNQXAC9IVRw
Title: Me at the zoo
Views: 172639597
Published at: 2005-04-23
Video Duration: 0:18
Video tags: me at the zoo, jawed karim, first youtube video
Likes: 8188077
Dislikes: 191986
Description: The first video on YouTube. While you wait for Part 2, listen to this great song: https://www.youtube.com/watch?v=zj82_v2R6ts
Channel Name: jawed
Channel URL: https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A
Channel Subscribers: 1.98M subscribers
But I instead get this :(
mattpopovich@MBP $ python3 extract_video_info.py 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
Traceback (most recent call last):
File "/Users/mattpopovich/Documents/extract_video_info.py", line 58, in <module>
data = get_video_info(url)
File "/Users/mattpopovich/Documents/extract_video_info.py", line 32, in get_video_info
result["likes"] = ''.join([ c for c in text_yt_formatted_strings[0].attrs.get("aria-label") if c.isdigit() ])
IndexError: list index out of range
I'm looking into it... Just wanted to document it now for the time being.
Looks like the ytInitialData
variable has a "defaultText":{"accessibility":{"accessibilityData":{"label":"##### likes"}}
which might be promising
line 1, in
import cv2
ModuleNotFoundError: No module named 'cv2'
Hi x$nth055,
Excellent code, thank you.
My system:
O/S: Win10
Python: 3.6.2
Firefox: 74.-(64-bit)
(do you need another information?)
target download site:
https://www.silky-europe.com/alle-producten?SID=dd9f2ff67051f25c98a7f7f98cc25ed6&limit=12&p=4
Your code was "cut&paste" to text editor so nothing changed in code.
command used to download:
python download_images.py https://www.silky-europe.com/alle-producten?SID=dd9f2ff67051f25c98a7f7f98cc25ed6&limit=12&p=4
result: images downloaded and folder created as expected. I am not too sure if entire compliment of web page images were downloaded.
error: 'limit' is not recognized as an internal or external command, operable program or batch file.
'p' is not recognized as an internal or external command, operable program or batch file.
Can you advise please? Is there something that I should be looking for in the error message?
Stay safe and well,
Tommy.
When I put all the code in server.py into VSCode, it suddenly shows an error Code is unreachable Pylance
and it seems because while True:
before :
# close client sockets
for cs in client_sockets:
cs.close()
# close server socket
s.close()
Can you update the code again, I need it :)
Hi -
May I assume the live barcode reader will run on a phone and be able to access the phone's camera? At a high level, how does that work? I have basic Python knowledge where I've built one web-based database-driven inventory management system and one simple 2D game but nothing more, really. So be gentle with me, heh.
Sincerely,
Scott Swain
This error pops up while training the skin cancer model. Changed the batch size to 1 but it didn't solve the problem.
Can i scrape video based on the Youtube Keywords...
"ethical-hacking/keylogger/"
Have latest code version and currently the line with:
name = f"[{name.upper()}]"
is causing a "SyntaxError: invalid syntax"
If I comment out the code above, I get:
"ImportError: No module named keyboard"
I have a virtual environment with the latest version of the keyboard package (0.13.4), I also ran the code in the terminal without the virtual environment.
Any tips on a fix?
Thanks
How would I make the chart prediction actually go in the future instead of just the past. Also can we export data from yfinance instead of manually downloading the csv and using that? That would be great!
Getting error:
`runfile('C:/Users/Jeff/Downloads/untitled1.py', wdir='C:/Users/Jeff/Downloads')
Traceback (most recent call last):
File "C:\Users\Jeff\Downloads\untitled1.py", line 120, in
for count, comment in enumerate(get_comments(url)):
File "C:\Users\Jeff\Downloads\untitled1.py", line 50, in get_comments
data = json.loads(data_str)
File "C:\Users\Jeff\anaconda3\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Jeff\anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Jeff\anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Expecting value`
Am recieving the following SyntaxError when running the code:
File "weather.py", line 62
URL += f"+(region)"
^
SyntaxError: invalid syntax
Looking at the code, the issue appears to be in this part:
if region:
region = region.replace(" ", "+")
URL += f"+{region}"
Troubleshooting now, interested to hear if anyone has a fix or has had this problem before.
Traceback (most recent call last):
File "Inbox.py", line 37, in <module>
msg = email.message_from_bytes(response[1])
AttributeError: 'module' object has no attribute 'message_from_bytes'
hello
when i run the python synflood.py --port 80 185.73.226.46
it reurns an error:
WARNING: No IPv4 address found on en1 !
WARNING: No IPv4 address found on en2 !
WARNING: more No IPv4 address found on bridge0 !
Traceback (most recent call last):
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/fields.py", line 236, in addfield
return s + self.struct.pack(self.i2m(pkt, val))
struct.error: required argument is not an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ali/Desktop/smorf/synflood.py", line 35, in <module>
send(p, loop=1, verbose=0)
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/sendrecv.py", line 425, in send
return _send(
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/sendrecv.py", line 395, in _send
results = __gen_send(socket, x, inter=inter, loop=loop,
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/sendrecv.py", line 360, in __gen_send
s.send(p)
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/arch/bpf/supersocket.py", line 403, in send
frame = raw(self.guessed_cls() / pkt)
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/compat.py", line 279, in raw
return bytes(x)
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 564, in __bytes__
return self.build()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 695, in build
p = self.do_build()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 678, in do_build
pay = self.do_build_payload()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 664, in do_build_payload
return self.payload.do_build()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 678, in do_build
pay = self.do_build_payload()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 664, in do_build_payload
return self.payload.do_build()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 675, in do_build
pkt = self.self_build()
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/packet.py", line 654, in self_build
p = f.addfield(self, p, val)
File "/Users/ali/Desktop/smorf/venv/lib/python3.9/site-packages/scapy/fields.py", line 238, in addfield
raise ValueError(
ValueError: Incorrect type of value for field dport:
struct.error('required argument is not an integer')
To inject bytes into the field regardless of the type, use RawVal. See help(RawVal)
Get the following error. Cannot figure out how to correct it.
Traceback (most recent call last):
File "test.py", line 103, in <module>
final_df = get_final_df(model, data)
File "test.py", line 43, in get_final_df
test_df[f"adjclose_{LOOKUP_STEP}"] = y_pred
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 3044, in __setitem__
self._set_item(key, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 3120, in _set_item
value = self._sanitize_column(key, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 3768, in _sanitize_column
value = sanitize_index(value, self.index)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 747, in sanitize_index
raise ValueError(
ValueError: Length of values (445) does not match length of index (447)
For the stock prediction example:
$ python3 train.py
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/im/.local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
File "train.py", line 1, in <module>
from stock_prediction import create_model, load_data
File "/home/im/lab/pythoncode-tutorials/machine-learning/stock-prediction/stock_prediction.py", line 15, in <module>
tf.random.set_seed(314)
File "/home/im/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation_wrapper.py", line 106, in __getattr__
attr = getattr(self._dw_wrapped_module, name)
AttributeError: module 'tensorflow._api.v1.random' has no attribute 'set_seed'
Hello, thank you for all the scripts and great work.
I tried Stock-prediction and stucked at the last Cell with :
----> mean_absolute_error = data["column_scaler"]["adjclose"].inverse_transform(mae.reshape(1, -1))[0][0]
print("Mean Absolute Error:", mean_absolute_error)
# predict the future price
AttributeError: 'float' object has no attribute 'reshape'
How can it be solved?
In addition, I wonder how to speed up the calculations - so far it takes couple of hours.
All the best
if name == "main":
import argparse
parser = argparse.ArgumentParser(description="YouTube Video Data Extractor")
parser.add_argument("url", help="URL of the YouTube video")
args = parser.parse_args()
# parse the video URL from command line
url = args.url
data = get_video_info(url)
# print in nice format
print(f"Title: {data['title']}")
print(f"Views: {data['views']}")
print(f"Published at: {data['date_published']}")
print(f"Video Duration: {data['duration']}")
print(f"Video tags: {data['tags']}")
print(f"Likes: {data['likes']}")
print(f"Dislikes: {data['dislikes']}")
print(f"\nDescription: {data['description']}\n")
print(f"\nChannel Name: {data['channel']['name']}")
print(f"Channel URL: {data['channel']['url']}")
print(f"Channel Subscribers: {data['channel']['subscribers'
usage: ipykernel_launcher.py [-h] url
ipykernel_launcher.py: error: unrecognized arguments: -f
Traceback (most recent call last):
File "C:\Users\abc\PycharmProjects\Project1\venv\Scripts\new.py", line 60, in
data = get_video_info(url)
File "C:\Users\abc\PycharmProjects\Project1\venv\Scripts\new.py", line 34, in get_video_info
result["likes"] = int(''.join([c for c in text_yt_formatted_strings[0].attrs.get("aria-label") if c.isdigit()]))
TypeError: 'NoneType' object is not iterable
I am trying this script on a video where like and dislike are hidden, so how to retrieve it in this scenario - Help If Possible
When I try to convert image to yolo image with "yolo_opencv.py", I get this error:
Traceback (most recent call last):
File "yolo_opencv.py", line 23, in <module>
net = cv2.dnn.readNetFromDarknet(config_path, weights_path)
cv2.error: OpenCV(3.4.2) /io/opencv/modules/dnn/src/darknet/darknet_io.cpp:684: error: (-215:Assertion failed) ifile.is_open() in function 'ReadDarknetFromWeightsFile'
How can I solve this problem? Thank you.
the generated html file is totally empty, I make a post request and a popup should appear, is it normal that it appears blank or something is not working?
I'm trying to implement the Pytorch code to extract the bounding boxes cordinates for (pseudo labeling). I'm printing the "boxes" variable and getting this output
[[tensor(0.4833), tensor(0.5783), tensor(0.4487), tensor(0.5920), tensor(0.9858), tensor(0.9875), tensor(1)]]
I'm confused as to the set up of the output i'm assuming it's (x, y, w, h, ?, ?, number_of_detected_imgs)
clarity would be appreciated thanks!
Traceback (most recent call last):
File "Inbox.py", line 39, in <module>
subject, encoding = decode_header(msg['Subject'])[0]
TypeError: list indices must be integers, not str
I tried deleting [0]
but it didn't work.
Hello
When I tried the .py like that python demo.py https://github.com -m 1 , I encountered this Traceback errors
Traceback (most recent call last):
File "demo.py", line 2, in
from requests_html import HTMLSession
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\requests_html.py", line 9, in
import pyppeteer
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer_init_.py", line 30, in
from pyppeteer.launcher import connect, launch, executablePath # noqa: E402
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\launcher.py", line 24, in
from pyppeteer.browser import Browser
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\browser.py", line 13, in
from pyppeteer.connection import Connection
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\connection.py", line 12, in
import websockets
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\websockets_init_.py", line 3, in
from .auth import *
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\websockets\auth.py", line 15, in
from .server import HTTPResponse, WebSocketServerProtocol
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\websockets\server.py", line 49, in
from .protocol import WebSocketCommonProtocol
File "C:\Users\Future\AppData\Local\Programs\Python\Python36\lib\site-packages\websockets\protocol.py", line 18, in
from typing import (
ImportError: cannot import name 'Deque'
Any ideas?
how can i insert my image inside the code ,
im unable to find the way please help
thank you sir
python -i x1.pdf x2.pdf x3.pdf -o final.pdf
Considers only the first file x1.pdf as merge candidate and ignores the rest.
The current code is
input_files = [str(x) for x in args['input_files'][0].split(',')]
As a result even if args['input_files'] contains list of input_files, only first file is considered.
needs to be replaced with
input_files = args['input_files']
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.