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.
Related
I would like to use the cryptography's module on Windows, I am using version 1.12 and Python 3.10.6, and I have some problems. Actually, when I run my script, I receive the error :
`
Traceback (most recent call last):
File "C:/Users/edoua/Documents/cryptographie.py", line 1, in <module>
from cryptography.fernet import Fernet
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\fernet.py", line 16, in <module>
from cryptography.hazmat.primitives.hmac import HMAC
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\hazmat\primitives\hmac.py", line 10, in <module>
from cryptography.hazmat.backends.openssl.hmac import _HMACContext
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\hazmat\backends\openssl\__init__.py", line 6, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 13, in <module>
from cryptography import utils, x509
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\__init__.py", line 7, in <module>
from cryptography.x509.base import (
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\base.py", line 28, in <module>
from cryptography.x509.extensions import (
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\extensions.py", line 25, in <module>
from cryptography.x509.general_name import (
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\general_name.py", line 9, in <module>
from email.utils import parseaddr
File "C:\Users/edoua/Documents\email.py", line 18, in <module>
server.login(email_address, email_password)
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\smtplib.py", line 739, in login
(code, resp) = self.auth(
File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\smtplib.py", line 641, in auth
response = encode_base64(initial_response.encode('ascii'), eol='')
NameError: name 'encode_base64' is not defined
`
It is coming from the smtplib.py file. Also, I precise that the module works perfectly, I can use all the functions of the module base64. So the problem is coming from the word 'encode_base64'. Please help !
I tried to launch my program, and that error occures, I expected that it was going to work.
You have a local module C:\Users/edoua/Documents\email.py that is shadowing the email module from the Python standard library. Rename email.py to something else, or move it to somewhere that isn't on the Python path.
I'm using windows 10, and I have a script to SSH to the device and do some configurations:
from Exscript import Account
from Exscript.protocols import SSH2
account = Account("user","password")
conn = SSH2()
conn.connect('192.168.200.2')
conn.login(account)
But I get the following error:
Traceback (most recent call last):
File "c:\Users\hp\Desktop\password-finder.py", line 2, in <module>
from Exscript.protocols import SSH2
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\__init__.py", line 34, in <module>
from .queue import Queue
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\queue.py", line 40, in <module>
from .util.decorator import get_label
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\util\decorator.py", line 28, in <module>
from ..protocols.exception import LoginFailure
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\protocols\__init__.py", line 26, in <module>
from ..util.url import Url
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\util\url.py", line 36, in <module>
from .collections import OrderedDefaultDict
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\util\collections.py", line 9, in <module>
from collections import OrderedDict, Callable, defaultdict
ImportError: cannot import name 'Callable' from 'collections' (c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)
Update:
Not a perfect solution but works for me:
remove Callable keyword in line 9 of file Exscript\util\collections.py:
from collections import OrderedDict, Callable, defaultdict
to:
from collections import OrderedDict, defaultdict
(I have to make an answer to comment sorry)
do you have collections installed in python? just to check open cmd and type:
pip install collections
if it says: Requirement already satisfied then i will dig deeper and see what I can find
edit: I'm having the same issue, ill try debugging
I am trying to connect Pepper to Dialogflow. The Dialogflow SDK is stored in the project folder/lib. The python version used by Pepper is 2.7. I use python 2.7.9.
self.folderName = os.path.join(self.framemanager.getBehaviorPath(self.behaviorId), "..\lib")
if self.folderName not in sys.path:
sys.path.append(self.folderName)
self.log(self.folderName)
import apiai
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
When running the code, I got the errors:
[ERROR] behavior.box :_safeCallOfUserMethod:281 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1338328200__root__test_1: Traceback (most recent call last):
File "C:\PROGRA~2\ALDEBA~1\CHOREG~1.1\lib\naoqi.py", line 271, in _safeCallOfUserMethod
func()
File "<string>", line 23, in onInput_onStart
File "C:\Users\AppData\Roaming\PackageManager\apps\.lastUploadedChoregrapheBehavior\behavior_1\..\lib\apiai\__init__.py", line 9, in <module>
from .requests.query import Entry
File "C:\Users\AppData\Roaming\PackageManager\apps\.lastUploadedChoregrapheBehavior\behavior_1\..\lib\apiai\requests\__init__.py", line 3, in <module>
from .request import Request
File "C:\Users\loadedChoregrapheBehavior\behavior_1\..\lib\apiai\requests\request.py", line 9, in <module>
from httplib import HTTPSConnection
ImportError: cannot import name HTTPSConnection
Any ideas how to solve it?
This program must be run on the robot, rather than on your computer.
I'm trying to build a discord bot, and I have this error that I can't seem to figure out that explicitly happens when I try to import discord.py
The error message is:
Traceback (most recent call last):
File "C:/Users/Pastry/PycharmProjects/PastryBot/sample.py", line 1, in <module>
import discord
File "C:\Python35\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Python35\lib\site-packages\discord\client.py", line 28, in <module>
from .user import User
File "C:\Python35\lib\site-packages\discord\user.py", line 27, in <module>
from .utils import snowflake_time
File "C:\Python35\lib\site-packages\discord\utils.py", line 31, in <module>
import asyncio
File "C:\Python35\lib\asyncio\__init__.py", line 21, in <module>
from .base_events import *
File "C:\Python35\lib\asyncio\base_events.py", line 18, in <module>
import concurrent.futures
File "C:\Python35\lib\concurrent\futures\__init__.py", line 17, in <module>
from concurrent.futures.process import ProcessPoolExecutor
File "C:\Python35\lib\concurrent\futures\process.py", line 55, in <module>
from multiprocessing.connection import wait
File "C:\Python35\lib\multiprocessing\connection.py", line 18, in <module>
import tempfile
File "C:\Python35\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
ImportError: cannot import name 'Random'
I tried using the sample code from the quickstart bot guide on their documentation page as well, and ran into the same error. I thought it was a problem with my version of discord.py so I tried to update it, and then re-ran the program but I'm still getting this error. Could anyone help enlighten me?
Did you download the discord.py library? that could be the the problem. What about the asyncio library? Those two are most likely.
I have some scripts that run every 30 minutes in cron that import paramiko. Seemingly at random, I will get one of these two errors during import:
Traceback (most recent call last):
...
File "build/bdist.linux-x86_64/egg/paramiko/__init__.py", line 65, in <module>
File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 42, in <module>
File "build/bdist.linux-x86_64/egg/paramiko/packet.py", line 39, in <module>
File "build/bdist.linux-x86_64/egg/Crypto/Hash/HMAC.py", line 66, in <module>
File "build/bdist.linux-x86_64/egg/Crypto/Util/strxor.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/Crypto/Util/strxor.py", line 6, in __bootstrap__
ImportError: dynamic module does not define init function (initstrxor)
-- OR --
Traceback (most recent call last):
...
File "build/bdist.linux-x86_64/egg/paramiko/__init__.py", line 65, in <module>
File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 53, in <module>
File "build/bdist.linux-x86_64/egg/Crypto/Cipher/ARC4.py", line 66, in <module>
File "build/bdist.linux-x86_64/egg/Crypto/Cipher/_ARC4.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/Crypto/Cipher/_ARC4.py", line 6, in __bootstrap__
ImportError: dynamic module does not define init function (init_ARC4)
Every time that I have seen this issue, simply rerunning the script allows paramiko to import correctly and the script to finish.
What can cause this issue? Any help is greatly appreciated.
While I have no idea what may be causing the error, it seems it's failing on the native parts of pycrypto, so you may want to retry a couple of times:
from time import sleep
n_tries= 3
import_success= False
while not import_success:
try:
from Crypto.Cipher import Blowfish, AES, DES3, ARC4
from Crypto.Hash import MD5, SHA, SHA256, HMAC
from Crypto import Random
from Crypto.PublicKey import DSA, RSA
from Crypto.Util import Counter, number
import_success= True
except ImportError:
if not n_tries:
raise #re-raise ImportError
n_tries-=1
sleep(1)