{"id":2817,"date":"2021-05-31T22:23:05","date_gmt":"2021-05-31T13:23:05","guid":{"rendered":"https:\/\/obenkyolab.com\/?p=2817"},"modified":"2022-01-25T23:42:43","modified_gmt":"2022-01-25T14:42:43","slug":"%e3%80%90python%e3%80%91pings%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%81%a7ping%e3%81%ae%e7%96%8e%e9%80%9a%e7%a2%ba%e8%aa%8d%e3%81%a8attributeerror-module-time-has-no-attribute-clock","status":"publish","type":"post","link":"https:\/\/obenkyolab.com\/?p=2817","title":{"rendered":"\u3010Python\u3011pings\u30e9\u30a4\u30d6\u30e9\u30ea\u3067ping\u306e\u758e\u901a\u78ba\u8a8d\u3068AttributeError: module &#8216;time&#8217; has no attribute &#8216;clock&#8217;\u3078\u306e\u5bfe\u51e6"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#%E6%A6%82%E8%A6%81\" >\u6982\u8981<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#%E7%92%B0%E5%A2%83\" >\u74b0\u5883<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#Step1_pings_%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB\" >Step1 : pings \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#Step2_pings%E3%81%AEimport\" >Step2 : pings\u306eimport<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#%E3%82%A8%E3%83%A9%E3%83%BC%E5%AF%BE%E5%87%A6%E6%96%B9%E6%B3%95\" >\u30a8\u30e9\u30fc\u5bfe\u51e6\u65b9\u6cd5<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#Step3_pings%E5%8B%95%E4%BD%9C%E7%A2%BA%E8%AA%8D\" >Step3  : pings\u52d5\u4f5c\u78ba\u8a8d<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/obenkyolab.com\/?p=2817\/#%E3%81%BE%E3%81%A8%E3%82%81\" >\u307e\u3068\u3081<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A6%82%E8%A6%81\"><\/span>\u6982\u8981<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Python\u3067\u30b5\u30fc\u30d0\u306a\u3069\u306e\u6b7b\u6d3b\u76e3\u8996\u3092\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u306e\u306f\u4e00\u5b9a\u306e\u9700\u8981\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002subprocess\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u5b9f\u73fe\u3067\u304d\u308b\u3089\u3057\u3044\u3067\u3059\u304c\u3001\u3082\u3063\u3068\u7c21\u5358\u306b\u4f7f\u3048\u308bpings\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u4f7f\u7528\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br>\u4f7f\u7528\u5148\uff1a<br>https:\/\/github.com\/satoshi03\/pings<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u4f7f\u7528\u3057\u305f\u4e2d\u3067AttributeError\u304c\u767a\u751f\u3057\u305f\u306e\u3067\u305d\u306e\u5bfe\u51e6\u6cd5\u306b\u3064\u3044\u3066\u3082\u8a18\u9332\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%92%B0%E5%A2%83\"><\/span>\u74b0\u5883<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Windows10<\/li><li>Python 3.8.7<\/li><\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u3067\u4f5c\u6210\u3057\u305f\u74b0\u5883\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-it-learning wp-block-embed-it-learning\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"6f4dJvlhwr\"><a href=\"https:\/\/obenkyolab.com\/?p=2582\">\u3010Python\u3011Windows\u3067Python+JupyterLab\u74b0\u5883\u306e\u69cb\u7bc9<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;\u3010Python\u3011Windows\u3067Python+JupyterLab\u74b0\u5883\u306e\u69cb\u7bc9&#8221; &#8212; Obenkyolab\" src=\"https:\/\/obenkyolab.com\/?p=2582&#038;embed=true#?secret=77jhSgLebZ#?secret=6f4dJvlhwr\" data-secret=\"6f4dJvlhwr\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step1_pings_%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB\"><\/span>Step1 : pings \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PyPI\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067pip\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>pip install pings\n----------------\nSuccessfully built pings\nInstalling collected packages: pings\nSuccessfully installed pings-0.0.1<\/code><\/pre><\/div>\n\n\n\n<p>pings-0.0.1\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step2_pings%E3%81%AEimport\"><\/span>Step2 : pings\u306eimport<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u65e9\u901fpyhton\u3092\u8d77\u52d5\u3057\u3066import pings\u3092\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import pings\n----------------\nTraceback (most recent call last):\t\t\t\t\n  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;\t\t\t\t\n  File &quot;C:\\Users\\&lt;user_profile&gt;\\.venv\\lib\\site-packages\\pings\\__init__.py&quot;, line 3, in &lt;module&gt;\t\t\t\t\n    from .ping import *\t\t\t\t\n  File &quot;C:\\Users\\&lt;user_profile&gt;\\.venv\\lib\\site-packages\\pings\\ping.py&quot;, line 13, in &lt;module&gt;\t\t\t\t\n    timer = time.clock\t\t\t\t\nAttributeError: module &#39;time&#39; has no attribute &#39;clock&#39;\t\t\t\t<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u898b\u308b\u3068\u3001ping.py\u306etimer = time.clock\u306b\u3066clock\u30e1\u30bd\u30c3\u30c9\u304c\u306a\u3044\u3088\u3001\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u81ea\u5206\u306e\u74b0\u5883\u306fpython3.8\u3067\u3059\u304c\u3001\u8abf\u3079\u308b\u3068\u3069\u3046\u3084\u30893.8\u3067\u306ftime.clock\u306f\u65e2\u306b\u7121\u304f\u306a\u3063\u3066\u3044\u308b\u3089\u3057\u3044\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\u30b5\u30a4\u30c8\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/58569361\/attributeerror-module-time-has-no-attribute-clock-in-python-3-8\">https:\/\/stackoverflow.com\/questions\/58569361\/attributeerror-module-time-has-no-attribute-clock-in-python-3-8<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%82%A8%E3%83%A9%E3%83%BC%E5%AF%BE%E5%87%A6%E6%96%B9%E6%B3%95\"><\/span>\u30a8\u30e9\u30fc\u5bfe\u51e6\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u30a8\u30e9\u30fc\u3092\u89e3\u6d88\u3059\u3079\u304f\u3001time.clock\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u7b87\u6240\u3092\u624b\u52d5\u3067\u4fee\u6b63\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>~\\site-packages\\pingsping.py\u3092\u958b\u304d\u3001\u8a72\u5f53\u7b87\u6240\u306etime.clock\u3092time.time\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>if\u00a0sys.platform.startswith(&quot;win32&quot;):\n\u00a0\u00a0\u00a0\u00a0#timer\u00a0=\u00a0time.clock\n\u00a0\u00a0\u00a0\u00a0timer\u00a0=\u00a0time.time\nelse:\n\u00a0\u00a0\u00a0\u00a0timer\u00a0=\u00a0time.time<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3067\u518d\u5ea6import pings\u3057\u305f\u3068\u3053\u308d\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002\u3072\u3068\u307e\u305a\u3053\u308c\u3067OK\u3068\u5224\u65ad\u3057\u3066\u3001\u3055\u3063\u305d\u304fpings\u3092\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step3_pings%E5%8B%95%E4%BD%9C%E7%A2%BA%E8%AA%8D\"><\/span>Step3  : pings\u52d5\u4f5c\u78ba\u8a8d<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/satoshi03\/pings\" data-type=\"URL\" data-id=\"https:\/\/github.com\/satoshi03\/pings\">GiHub<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import pings\np = pings.Ping()\nresponse = p.ping(&quot;google.com&quot;)\nresponse.is_reached()\n&gt;&gt;&gt; True\nresponse.print_messages()\n&gt;&gt;&gt;&gt; PING google.com (172.217.24.142): 55 data bytes\n&gt;&gt;&gt;&gt; 47 bytes from 172.217.24.142: icmp_seq=0 ttl=110 time=87.805 m<\/code><\/pre><\/div>\n\n\n\n<p>\u4e0a\u8a18\u306e\u901a\u308a\u3001python\u304b\u3089ping\u3092\u901a\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%81%BE%E3%81%A8%E3%82%81\"><\/span>\u307e\u3068\u3081<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>pings\u306f\u975e\u5e38\u306b\u77ed\u304f\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30fc\u30c9\u3067ping\u306e\u758e\u901a\u78ba\u8a8d\u3092\u884c\u3048\u308b\u305f\u3081\u975e\u5e38\u306b\u826f\u3044\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3057\u305f\u3002<br>3.8\u74b0\u5883\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3057\u305f\u304c\u3001\u3059\u3050\u306b\u89e3\u6c7a\u3067\u304d\u305f\u306e\u3067\u3042\u307e\u308a\u82e6\u52b4\u305b\u305a\u4f7f\u3048\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Python\u3092\u57fa\u672c\u304b\u3089\u5b66\u3076\u306b\u306f\u30b3\u30c1\u30e9\u304c\u304a\u3059\u3059\u3081<\/span><\/strong><\/p>\n\n\n\n<iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"https:\/\/rcm-fe.amazon-adsystem.com\/e\/cm?ref=qf_sp_asin_til&amp;t=sebone0f-22&amp;m=amazon&amp;o=9&amp;p=8&amp;l=as1&amp;IS2=1&amp;detail=1&amp;asins=4873117380&amp;linkId=297b7c02711c763e782bcb2fa89f3cb2&amp;bc1=000000&amp;lt1=_blank&amp;fc1=333333&amp;lc1=0066c0&amp;bg1=ffffff&amp;f=ifr\">\n    <\/iframe>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Python\u3067\u30b5\u30fc\u30d0\u306a\u3069\u306e\u6b7b\u6d3b\u76e3\u8996\u3092\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u306e\u306f\u4e00\u5b9a\u306e\u9700&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1218,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/obenkyolab.com\/?p=2817","footnotes":""},"categories":[7],"tags":[],"class_list":["post-2817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","ja"],"_links":{"self":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/2817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2817"}],"version-history":[{"count":14,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/2817\/revisions"}],"predecessor-version":[{"id":4713,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/2817\/revisions\/4713"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/media\/1218"}],"wp:attachment":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}