Fórum Não consigo usar bibliotecas para programar em python #605290
10/09/2019
0
Sempre que uso o comando import (Alguma biblioteca) eu não consigo obter o resultado que quero, eu tentei criar um socket com a biblioteca socket
só que não funcionou...
o script é esse:
import socket
O erro é esse:
Tracerback (most recent call last):
File "./socket.py", line 2, in <module>
import socket
File "/root/socket.py", line 5, in <module>
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: ''''Module'''' object has not attribute ''''AF_INET''''
só que não funcionou...
o script é esse:
import socket
ip = input("Digite um ip")
port = input("Digite uma porta")
meusocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if meusocket.connect_ex((ip, port)):
print ("Porta fechada")
else:
print ("Porta aberta")O erro é esse:
Tracerback (most recent call last):
File "./socket.py", line 2, in <module>
import socket
File "/root/socket.py", line 5, in <module>
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: ''''Module'''' object has not attribute ''''AF_INET''''
Pedro Mariane
Curtir tópico
+ 0
Responder
Posts
14/09/2019
Alexandre Deus
Sempre que uso o comando import (Alguma biblioteca) eu não consigo obter o resultado que quero, eu tentei criar um socket com a biblioteca socket
só que não funcionou...
o script é esse:
import socket
O erro é esse:
Tracerback (most recent call last):
File "./socket.py", line 2, in <module>
import socket
File "/root/socket.py", line 5, in <module>
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: ''''Module'''' object has not attribute ''''AF_INET''''
só que não funcionou...
o script é esse:
import socket
ip = input("Digite um ip")
port = input("Digite uma porta")
meusocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if meusocket.connect_ex((ip, port)):
print ("Porta fechada")
else:
print ("Porta aberta")O erro é esse:
Tracerback (most recent call last):
File "./socket.py", line 2, in <module>
import socket
File "/root/socket.py", line 5, in <module>
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: ''''Module'''' object has not attribute ''''AF_INET''''
Olá Pedro, tudo bem? Você importou a biblioteca?
Existem gerenciadores de dependências que fazem isso pra você. O mais utilizado é o pip.
pip install sockets
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)