python - 如何在 python 3.5.3 中修复“`OPENSSL_1_1_0j' not found”
问题描述
我正在使用超声波传感器在我的树莓派上编写一些代码,该传感器可以检测人们何时走到它前面。这很好用,所以我去实现将命令发送到我的计算机以执行一些代码的代码,但我遇到了一些错误。这是使用 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 install 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)
解决方案
推荐阅读
- python - 如何在 Python 中创建日期时间使用跟踪器?
- c# - 带有 Docker 的 HTTP ERROR 404 dotnet 核心 API
- virtualization - 我可以在个人计算机或笔记本电脑中保留或安装多个 Hypervisor Type-2 吗?
- javascript - 对 networkD3 linkDistance 和 linkWidth 使用数据集中的不同列
- javascript - 如何在输入字段中将光标移动到特定值之前?
- javascript - 如何修复表格的重复
- vue.js - VueJs嵌套组件不能发出函数的结果
- bash - 无法创建文件:没有这样的文件或目录
- javascript - 让 Intersection Observer 更精确、更高效
- java - ResultSet.updateRow() 是否提交,即结束事务?