Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.maint.python > #11420

Re: AttributeError: module 'socket' has no attribute 'timeout'

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Neil Williams <codehelp@debian.org>
Newsgroups linux.debian.maint.python
Subject Re: AttributeError: module 'socket' has no attribute 'timeout'
Date Thu, 25 Apr 2019 10:20:02 +0200
Message-ID <xQHLQ-3OM-7@gated-at.bofh.it> (permalink)
References <xQGZr-3fY-3@gated-at.bofh.it>
X-Mailbox-Line From debian-python-request@lists.debian.org Thu Apr 25 08:10:21 2019
Old-Return-Path <codehelp@debian.org>
X-Amavis-Spam-Status No, score=-11.7 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, BODY_8BITS=1.5, FOURLA=0.1, GMAIL=1, LDO_WHITELIST=-5, PGPSIGNATURE=-5, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham autolearn_force=no
X-Policyd-Weight using cached result; rate: -4.6
X-Mailer Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha256; boundary="Sig_/u/ndQnbqmmtpXU4Scr.ksQ="; protocol="application/pgp-signature"
X-Mailing-List <debian-python@lists.debian.org> archive/latest/16892
List-ID <debian-python.lists.debian.org>
List-URL <https://lists.debian.org/debian-python/>
List-Archive https://lists.debian.org/msgid-search/20190425091020.6e5b15e8@sylvester.codehelp
Approved robomod@news.nic.it
Lines 106
Organization linux.* mail to news gateway
Sender robomod@news.nic.it
X-Original-Cc "debian-python@lists.debian.org" <debian-python@lists.debian.org>
X-Original-Date Thu, 25 Apr 2019 09:10:20 +0100
X-Original-Message-ID <20190425091020.6e5b15e8@sylvester.codehelp>
X-Original-References <CAB+BSg_YBw+a2L2+PnNoM1MWq+6tGgcJ=Eyo_g0ZC_J2sTLEbw@mail.gmail.com>
Xref csiph.com linux.debian.maint.python:11420

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, 25 Apr 2019 10:04:46 +0300
Artem Golubev <agolubev.n@gmail.com> wrote:

> Hello,  I’m using python3.5, python3.7 on Debian 9 stretch

Simply rename the script and delete any socket.pyc file in the same
directory.

* Do not name your script using the name of a module that you will be
  importing:

>   File "/root/python/projects/test/socket.py", line 7, in <module>

That should be .../test/socket-test.py or socket-script.py
anything except the name of the module you will be importing from
elsewhere.

> This is my code:

The code itself is fine.

> 
> ———————-
> import socket
> 
> host =  'google.com’

The quotation marks here were mangled by your email client but once
that is fixed, the code works fine.

> port = 80
> 
> try:
>     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>     sock.settimeout(0.1)
>     result = sock.connect_ex((host, port))
>     if result == 0:
>         print('Port is UP')
>     else:
>         print('Port is DOWN')
> except socket.timeout as e:
>     print(e)
> ——————————
> 
> 
> When I execute my code I receive this error
> 
> ***************
> Traceback (most recent call last):
>   File "/root/python/projects/test/socket.py", line 7, in <module>
>     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> AttributeError: module 'socket' has no attribute 'AF_INET'
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "socket.py", line 1, in <module>
>     import socket
>   File "/root/python/projects/test/socket.py", line 14, in <module>
>     except socket.timeout as e:
> AttributeError: module 'socket' has no attribute 'timeout'
> ******************
> recently everything worked fine, but some time ago this error
> appeared. And on other OS (Ubuntu, FreeBSD), the code works without
> errors. Please help:) sorry for my English
> 
> -- 
> С уважением,
> Артём


-- 


Neil Williams
=============
http://www.linux.codehelp.co.uk/

Back to linux.debian.maint.python | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

AttributeError: module 'socket' has no attribute 'timeout' Artem Golubev <agolubev.n@gmail.com> - 2019-04-25 09:30 +0200
  Re: AttributeError: module 'socket' has no attribute 'timeout' Alexandros Afentoulis <alexaf@bloom.re> - 2019-04-25 10:20 +0200
  Re: AttributeError: module 'socket' has no attribute 'timeout' Neil Williams <codehelp@debian.org> - 2019-04-25 10:20 +0200

csiph-web