如何修复python 3.5.3中的“找不到OPENSSL_1_1_0j”

时间:2019-09-16 07:25:43

标签: python linux ssh raspberry-pi paramiko

我正在使用超声波传感器在树莓派上编写一些代码,该传感器可以检测人们何时走在它的前面。这很好用,所以我去实现了将命令发送到计算机以执行一些代码的代码,但出现了一些错误。这是使用paramiko SSH到我的计算机中的。到目前为止,这是代码:

import RPi.GPIO as GPIO
import time


import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('computer', username='user', password='password')

GPIO.setmode(GPIO.BOARD)

GPIO_TRIGGER = 7
GPIO_ECHO = 11
#set GPIO direction (IN / OUT)
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)
dis1 = 0
dis2 = 0
def distance():
    # set Trigger to HIGH
    GPIO.output(GPIO_TRIGGER, True)

    # set Trigger after 0.01ms to LOW
    time.sleep(0.00001)
    GPIO.output(GPIO_TRIGGER, False)

    StartTime = time.time()
    StopTime = time.time()

    # save StartTime
    while GPIO.input(GPIO_ECHO) == 0:
        StartTime = time.time()

    # save time of arrival
    while GPIO.input(GPIO_ECHO) == 1:
        StopTime = time.time()

    # time difference between start and arrival
    TimeElapsed = StopTime - StartTime
    # multiply with the sonic speed (34300 cm/s)
    # and divide by 2, because there and back
    distance = (TimeElapsed * 34300) / 2


    return distance

if __name__ == '__main__':
    try:
        while True:
            diff=0
            dist = distance()
            if dis1 == 0:
                dis1 = dist
            elif dis1 != 0 and dis2 == 0:
                dis2 = dist
            if dis1 != 0 and dis2 !=0:
                diff = dis1 - dis2
                print(diff)
                dis1 = 0
                dis2 = 0
            if diff > 5 or diff < -5:
                    print("human")
                    stdin, stdout, stderr = client.exec_command('ls')
            print ("Measured Distance = %.1f cm" % dist)
            time.sleep(0.1)
        # Reset by pressing CTRL + C
    except KeyboardInterrupt:
        print("Measurement stopped by User")
        GPIO.cleanup()

Pip安装paramiko无法正常工作,因此我不得不升级到3.5,这使我找到了位置,但是当我运行代码时,我得到了这个。

Traceback (most recent call last):
  File "sonic2.py", line 4, in <module>
    import paramiko
  File "/usr/local/lib/python3.5/dist-packages/paramiko/__init__.py", line 22, in <module>
    from paramiko.transport import SecurityOptions, Transport
  File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 129, in <module>
    class Transport(threading.Thread, ClosingContextManager):
  File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 190, in Transport
    if KexCurve25519.is_available():
  File "/usr/local/lib/python3.5/dist-packages/paramiko/kex_curve25519.py", line 30, in is_available
    X25519PrivateKey.generate()
  File "/usr/local/lib/python3.5/dist-packages/cryptography/hazmat/primitives/asymmetric/x25519.py", line 38, in generate
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/usr/local/lib/python3.5/dist-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/usr/local/lib/python3.5/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 74, in <module>
    from cryptography.hazmat.bindings.openssl import binding
  File "/usr/local/lib/python3.5/dist-packages/cryptography/hazmat/bindings/openssl/binding.py", line 15, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1: version `OPENSSL_1_1_0j' not found (required by /usr/local/lib/python3.5/dist-packages/cryptography/hazmat/bindings/_openssl.abi3.so)

0 个答案:

没有答案