我在 Raspberry Pi 修订版 B 上运行 Rrapbian。
我按照此网页上的说明下载了模块 python-snap7:Snap7 Installation
我尝试了两次:一次使用 pip,另一次手动执行。但是,我通过setup.py build然后 安装了它setup.py install。
如果我尝试创建客户端,则会出现以下错误:
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import snap7
>>> c = snap7.client.Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/snap7/client.py", line 29, in __init__
self.library = load_library()
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 48, in load_library
return Snap7Library(lib_location).cdll
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 40, …Run Code Online (Sandbox Code Playgroud) 您好我一直在为我的python代码中的主文件创建一个无限的While True循环.我正在研究Raspberry Pi,我的目标是每当其中一个GPIO引脚检测到输入时,它就会打印出一个字符串.然而,当我按下一个按钮时,它将无限地打印它,它停止的唯一方法是按Ctrl-C.虽然它一遍又一遍地打印相同的字符串,但没有其他按钮会改变发生的事情.我做错了什么,我忘记了某个地方的一步?
import RPi.GPIO as GPIO
import time
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(26, GPIO.IN)
GPIO.setup(19, GPIO.IN)
GPIO.setup(13, GPIO.IN)
GPIO.setup(6, GPIO.IN)
input_A = GPIO.input(26)
input_B = GPIO.input(19)
input_C = GPIO.input(13)
input_D = GPIO.input(6)
while True:
if input_A == True:
print('A was pushed')
if input_B == True:
print('B was pushed')
if input_C == True:
print('C was pushed')
if input_D == True:
print('D was pushed')
sleep(1.5);
Run Code Online (Sandbox Code Playgroud) 编辑
Raspbian Jessie Lite 不会打开 LXTerminal gui - 它只是一个控制台窗口 - 所以除非有办法打开一个新的“控制台”窗口,否则我需要安装 lxterminal
我想运行一个 bash 脚本,最后open a new command in another LXTerminal window让它运行,而我的登录窗口中还有命令行,当 bash 脚本结束时。
我在 Pi 3 上运行 Raspbian Jessie Lite
我是 Linux 世界的新手 - 所以我尝试从命令行输入 lxterm、lxterminal、LXTerminal,显然误解了需要什么。
我也试过使用“&”在后台运行命令,但它似乎需要终端输出,因为它失败了,我不明白为什么。它本身运行良好,但将大量连续文本转储到终端。
是否可以在 Jessie Lite 中打开一个新的终端窗口 - 如果可以的话,我可以弄清楚如何在启动时将命令传递给它
希望这是一个简单的解决方案,因为我对 Linux 世界很陌生
编辑
请注意,如果可能的话,我愿意下载任何实用程序或其他终端
谢谢
我在制作一个简单的服务器/客户端套接字python程序时遇到麻烦。基本上,我的服务器(RPi3)必须将视频(使用Gstreamer)流式传输到客户端(Fedora 24)。问题在于,在我的Fedora中,我可以使用Gstreamer像这样导入库:
import gi
gi.require_version('Gst', '1.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gst, GObject, Gtk
Run Code Online (Sandbox Code Playgroud)
但是在我的Raspbian中,我不能这样做,因为:
Traceback (most recent call last):
File "peerMain.py", line 12, in <module>
gi.require_version('Gst', '1.0')
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 100, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available
Run Code Online (Sandbox Code Playgroud)
我尝试了很多事情,例如import gst或pygst。我也尝试安装一些数据包
sudo apt-get install libgstreamer1.0-dev libgstreamer1.0-0-dbg libgstreamer1.0-0 gstreamer1.0-tools gstreamer-tools gstreamer1.0-doc gstreamer1.0-x
Run Code Online (Sandbox Code Playgroud)
但是结果是
gstreamer1.0-tools is already the newest version.
gstreamer1.0-x is already the newest version.
libgstreamer1.0-0 is already the newest version.
libgstreamer1.0-0 set to …Run Code Online (Sandbox Code Playgroud) 首先是这样做的:
systemctl stop mosquitto
update-rc.d mosquitto remove
rm /etc/init.d/mosquitto
Run Code Online (Sandbox Code Playgroud)
单元文件如下:
[Unit]
Description=MQTT v3.1 message broker
After=network.target
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Restart=always
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
的结果:
sudo systemctl status mosquitto -l
Run Code Online (Sandbox Code Playgroud)
是:
? mosquitto.service - MQTT v3.1 message broker
Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled)
Active: failed (Result: start-limit) since Sun 2017-01-01 19:44:03 GMT; 3min 23s ago
Process: 683 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 683 (code=exited, status=1/FAILURE)
Jan 01 19:44:03 raspberrypi systemd[1]: Unit mosquitto.service entered failed state.
Jan 01 19:44:03 …Run Code Online (Sandbox Code Playgroud) 我阅读了有关流浪错误的所有其他问答,但找不到与我的问题类似的任何内容...
所以:我需要在 Raspberry Pi 3 Model B(在 RASPBIAN JESSIE LITE 内核 v.4.4 上运行)上为 pybluez [ https://github.com/karulis/pybluez ]添加 BLE 支持,并且在构建 gattlib 时我得到了这些错误的大量列表(这是控制台输出的扩展副本:https : //pastebin.com/KjRB5rB7 ):
/usr/include/boost/python.hpp:5:1: error: stray ‘\2’ in program
/usr/include/boost/python.hpp:5:1: error: stray ‘\264’ in program
/usr/include/boost/python.hpp:5:1: error: stray ‘\334’ in program
/usr/include/boost/python.hpp:5:1: error: stray ‘\354’ in program
/usr/include/boost/python.hpp:5:1: error: stray ‘\377’ in program
/usr/include/boost/python.hpp:5:1: error: stray ‘\3’ in program
Run Code Online (Sandbox Code Playgroud)
我知道这是字符编码的问题,但对我来说这发生在下载的代码上看起来很奇怪。
有没有办法解决这个问题并继续安装?
我通过在 OsX 10.10.5 上运行的 MacBookPro 连接到 ssh,并且 hpp 文件的字符集是 bynary。
谢谢
我不想检查它是否具有 Internet 连接!我只是想检查它是否已连接到 WiFi 网络(我已经在 WPA_supplicant 文件中提供了它的 SSID)。此网络将无法访问 Internet。
我想安装systemd(github)库。
但是,执行
sudo pip3 install systemd
Run Code Online (Sandbox Code Playgroud)
导致此错误:
命令“ /usr/local/bin/python3.6 -u -c”导入setuptools,标记化;file ='/ tmp / pip-install-c97m6cn0 / systemd / setup.py'; f = getattr(tokenize,'open',open)(file); code = f.read()。replace('\ r \ n ','\ n'); f.close(); exec(compile(code,file,'exec')))“ install --record /tmp/pip-record-gqnrg4wd/install-record.txt --single-版本外部管理的--compile“在/ tmp / pip-install-c97m6cn0 / systemd /中失败,错误代码为1
我试图升级setuptools,但这不能解决我的问题:
sudo pip3 install --upgrade setuptools
Run Code Online (Sandbox Code Playgroud)
这里是完整的控制台输出:
$ sudo pip3 install systemd Collecting systemd
使用缓存的 https://files.pythonhosted.org/packages/d4/c2/2195b049effd866b5d26926e672be83fc6f3263aa71ea0639e8eab44851e/systemd-0.16.1.tar.gz 为收集的软件包构建轮子:systemd为systemd运行setup.py bdist_wheel ...错误完整的输出结果命令/ usr / bin / python3 -u -c“导入setuptools,标记化;文件 ='/ tmp …
背景
我正在尝试为在 Raspberry 3 上运行的 Rasbian 构建一个示例 REST api 应用程序。我使用cpprestsdk.
示例包含以下头文件:
#include <condition_variable>
#include <mutex>
#include <iostream>
static std::condition_variable _condition;
static std::mutex _mutex;
namespace cfx {
class InterruptHandler {
public:
static void hookSIGINT() {
signal(SIGINT, handleUserInterrupt);
}
static void handleUserInterrupt(int signal){
if (signal == SIGINT) {
std::cout << "SIGINT trapped ..." << '\n';
_condition.notify_one();
}
}
static void waitForUserInterrupt() {
std::unique_lock<std::mutex> lock { _mutex };
_condition.wait(lock);
std::cout << "user has signaled to interrup program..." << '\n';
lock.unlock();
} …Run Code Online (Sandbox Code Playgroud) 按照此处概述的命令,我无法在运行raspbian buster的Raspberry PI 4上安装docker。
以下是我依次尝试的命令:
1) apt-get update
2) apt-get install apt-transport-https ca-certificates software-properties-common
3)
add-apt-repository \
"deb https://apt.dockerproject.org/repo/ \
raspbian-$(lsb_release -cs) \
main"
Run Code Online (Sandbox Code Playgroud)
运行以上命令后,我尝试运行apt-get update:
root@raspberrypi:/home/pi# apt-get update
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Err:2 https://apt.dockerproject.org/repo raspbian-buster InRelease
403 Forbidden [IP: 13.249.111.113 443]
Ign:3 https://download.docker.com/linux/raspbian 10 InRelease
Err:4 https://download.docker.com/linux/raspbian 10 Release
404 Not Found [IP: 13.249.109.27 443]
Hit:5 http://raspbian.raspberrypi.org/raspbian buster InRelease
Reading package lists... Done
E: Failed to fetch https://apt.dockerproject.org/repo/dists/raspbian-buster/InRelease 403 Forbidden [IP: 13.249.111.113 443]
E: The …Run Code Online (Sandbox Code Playgroud)