im creating a packet capture program that will flash LEDs on a map depending on where the packet came from.
for locating the country the ip is in ive decided to use ipinfo.io
downloaded with command pip install ipinfo
however my program doesnt get past the import ipinfo line
i get ImportError: cannot import name abstractmethod
this program is on a raspberry pi 3 b
thanks for any help given its much appreciated.
if you need anything other information i am more than happy to provide. seen as its a lockdown in the uk ill be here basically all day everyday
edit:
so this is what i get when i run the code:WARNING: No route found for IPv6 destination :: (no default route?)
Traceback (most recent call last):
File "./VPCPRO.py", line 5, in <module>
import ipinfo
File "/usr/local/lib/python2.7/dist-packages/ipinfo/__init__.py", line 1, in <module>
from .handler import Handler
File "/usr/local/lib/python2.7/dist-packages/ipinfo/handler.py", line 11, in <module>
from .cache.default import DefaultCache
File "/usr/local/lib/python2.7/dist-packages/ipinfo/cache/default.py", line 5, in <module>
import cachetools
File "/usr/local/lib/python2.7/dist-packages/cachetools/__init__.py", line 3, in <module>
from .cache import Cache
File "/usr/local/lib/python2.7/dist-packages/cachetools/cache.py", line 1, in <module>
from .abc import DefaultMapping
File "/usr/local/lib/python2.7/dist-packages/cachetools/abc.py", line 1, in <module>
from abc import abstractmethod
ImportError: cannot import name abstractmethod
this is the code where the error hits
#!/usr/bin/env python
from scapy.all import *
import RPi.GPIO as GPIO
import time
import ipinfo
access_token = 'dadadadheudhq'(not the actual token)
GPIO.setmode(GPIO.BOARD)
LATCH = 12
CLK = 13
dataBit = 11
handler = ipinfo.getHandler(access_token)
okay so i figured out that i need to run this in python 3 for the error not to show however this means that scapy now will not run so. i guess ill have to make a new file for ipinfo and use it in the main file
Related
I've recently had a problem with (i think) the os module in python:
Traceback (most recent call last):
File "main.py", line 9, in <module>
api = getApi(os.environ['consumer_key'], os.environ['consumer_secret'], os.environ['access_token_key'], os.environ['access_token_secret'])
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\os.py", line 681, in __getitem__
raise KeyError(key) from None
KeyError: 'consumer_key'
my code of main.py is:
from config import getApi
import os
import sys
import time
print()
api = getApi(os.environ['consumer_key'], os.environ['consumer_secret'], os.environ['access_token_key'], os.environ['access_token_secret'])
my code of config.py is
import twitter
import os
def getApi(consumer_key, consumer_secret, access_token_key, access_token_secret):
return twitter.Api(consumer_key='*********',
consumer_secret='*********',
access_token_key='*********',
access_token_secret='*********')
Send tweets with the postUpdate is possible if I write the keys in the main.py but when I put the keys in the config.py, it don't works
Can anyone help me please ?
It's not an error with the os module, the keys simply aren't in the enviroment. If you're using a .env file you should use a module like dotenv to load the file.
After updating scipy, numpy and pandas to the newest versions, I receive the following error whenever I attempt to run my code on a Windows 10 machine with Python 3.7.4:
Traceback (most recent call last):
...
File "Path\To\MyClass.py", line 3, in <module>
import scipy.io as sio
File "Path\To\Anaconda\lib\site-packages\scipy\__init__.py", line 68, in <module>
from ._lib.deprecation import _deprecated
File "Path\To\Anaconda\lib\site-packages\scipy\_lib\__init__.py", line 12, in <module>
from scipy._lib._testutils import PytestTester
ValueError: source code string cannot contain null bytes
This is how the last file looks like:
"""
Module containing private utility functions
===========================================
The ``scipy._lib`` namespace is empty (for now). Tests for all
utilities in submodules of ``_lib`` can be run with::
from scipy import _lib
_lib.test()
"""
from scipy._lib._testutils import PytestTester
test = PytestTester(__name__)
del PytestTester
Am I running into a bug or is my setup broken?
I managed to solve this issue by reinstalling Anaconda. I still don't know the source of the problem though.
I haven't updated anything recently that I can think of that would have impacted nacl and the signing process for paramiko, but now it will not work. I have reinstalled paramiko, and netmiko and made sure all of the crypto libraries are up to date. I am at a loss what else to do, any thoughts?
from netmiko import ConnectHandler
...
def main(device_list):
username = input("\nWhat is your username? -> ")
password = getpass.getpass("\nWhat is your password? -> ")
for host in device_list:
juniper_device = {
'device_type': 'juniper',
'ip': host,
'username': username,
'password': password,
'verbose': False
}
Netmiko uses the Paramiko library to make SSH connections. This bit of code is what sets up the device definition.
Here is the stack trace associated with the creation of the device and the opening of an ssh connection.
Traceback (most recent call last):
File "./get_running-config.py", line 5, in <module>
from netmiko import ConnectHandler
File "/usr/local/lib/python3.4/dist-packages/netmiko/__init__.py", line 8, in <module>
from netmiko.ssh_dispatcher import ConnectHandler
File "/usr/local/lib/python3.4/dist-packages/netmiko/ssh_dispatcher.py", line 4, in <module>
from netmiko.a10 import A10SSH
File "/usr/local/lib/python3.4/dist-packages/netmiko/a10/__init__.py", line 2, in <module>
from netmiko.a10.a10_ssh import A10SSH
File "/usr/local/lib/python3.4/dist-packages/netmiko/a10/a10_ssh.py", line 4, in <module>
from netmiko.cisco_base_connection import CiscoSSHConnection
File "/usr/local/lib/python3.4/dist-packages/netmiko/cisco_base_connection.py", line 3, in <module>
from netmiko.base_connection import BaseConnection
File "/usr/local/lib/python3.4/dist-packages/netmiko/base_connection.py", line 13, in <module>
import paramiko
File "/usr/local/lib/python3.4/dist-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/local/lib/python3.4/dist-packages/paramiko/transport.py", line 57, in <module>
from paramiko.ed25519key import Ed25519Key
File "/usr/local/lib/python3.4/dist-packages/paramiko/ed25519key.py", line 22, in <module>
import nacl.signing
File "/usr/local/lib/python3.4/dist-packages/nacl/signing.py", line 19, in <module>
import nacl.bindings
File "/usr/local/lib/python3.4/dist-packages/nacl/bindings/__init__.py", line 17, in <module>
from nacl.bindings.crypto_box import (
File "/usr/local/lib/python3.4/dist-packages/nacl/bindings/crypto_box.py", line 27, in <module>
crypto_box_SEEDBYTES = lib.crypto_box_seedbytes()
AttributeError: cffi library '_sodium' has no function, constant or global variable named 'crypto_box_seedbytes'
After a lot of tinkering with the cryptography and subsequent modules, I just fresh installed all related libraries and things work now. Not really sure how it got in this state unfortunately but it was easier to just start over.
Unless you post the code, some guessing is needed:
Maybe the problem is similar to https://github.com/mitmproxy/mitmproxy/issues/2372, where it was solved by installing the cryptography package in version 1.9.
System : XP, work with python 2.7
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import json
File "C:\Python27\ArcGIS10.1\lib\json\__init__.py", line 108, in <module>
from .decoder import JSONDecoder
File "C:\Python27\ArcGIS10.1\lib\json\decoder.py", line 7, in <module>
from json import scanner
ImportError: cannot import name scanner
Anyone can explain me how to manage this error please ???
this morning I haven't got this problem, but this afternoon my script won't work ((
I think this is caused by relative import path,
File "C:\Python27\ArcGIS10.1\lib\json\decoder.py", line 7,
from json import scanner
it's trying to import scanner from
C:\Python27\ArcGIS10.1\lib\json
I have problems when try to import pywhois module, i can import my own module but still have troubles when import pywhois. I moved the pywhois folder in my project folder domain, the screentshot is below:
This is the import and calling statment below:
import part:
from pywhois import *
calling part:
w = whois('hackbo.com')
self.response.out.write(w)
The problems is it will always throw a http 500 error, error text is below:
Traceback (most recent call last):
File "/home/li/Desktop/google_appengine/google/appengine/ext/webapp/__init__.py", line 700, in __call__
handler.get(*groups)
File "/home/li/Desktop/google_appengine/domain/main.py", line 43, in get
w = whois('hackbo.com')
File "pywhois/__init__.py", line 12, in whois
text = nic_client.whois_lookup(None, domain, 0)
File "pywhois/whois.py", line 157, in whois_lookup
result = self.whois(query_arg, nichost, flags)
File "pywhois/whois.py", line 100, in whois
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: 'module' object has no attribute 'socket'
What is this error means? why i could import my own module but can not import pywhois?
Google App Engine doesn't support the socket module, which pywhois uses. It allows you to import socket, but it's an empty module.
import whois
site = input ("Enter Site : ")
n = whois.whois (site)
print (n)
this is best whois
Enjoy that, easy.