The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

3

In order to store the script’s text output in a log file, you can change the ExecStart line to: ExecStart=/usr/bin/python3 /home/pi/sample.py > /home/pi/sample.log 2>&1 This is wrong, although I notice there are a few Raspberry Pi oriented tutorials that claim it will work. It will not work because > (and 2>&1) are POSIX shell ...


3

If you're expecting a GUI browser to open, the DISPLAY environment variable may need to be explicitly set so that the browser the webbrowser module opens knows where to show itself. Otherwise it would likely not start at all and instead crash, not finding a valid GUI. For a systemd.service, you would do this by adding the line Environment=DISPLAY=:0 to the ...


3

Just haven't a monitor by hand so I can't test it but here are some ideas how it could work with reference to this accepted answer How to make a service to run a python script which includes browser automation. First of all we have a graphical output so the multi-user.target isn't enough. It is only for the text console. We have to use the graphical.target. ...


1

I had an issue like that with one of my Python projects, where I needed a Bash script with the steps to run my program to run not only after the Raspberry Pi boots, but also after the GUI loads. What worked for me was following the instructions in one of the posts in the "How to launch programs on LXDE startup" topic in the raspberypi.org forums, depending ...


1

Ok I figured it out. I already had installed h5py by the following lines as in this link: sudo apt-get install libhdf5-dev sudo apt-get install libhdf5-serial-dev sudo python3 -m pip install h5py And after those following this link sudo apt-get install netcdf-bin libnetcdf-dev sudo python3 -m pip install netcdf4 And now import netCDF4 works. By the way,...


1

You should use a larger value for sleep. Start with a really large value, then reduce it to find the minimum value, then add some safety margin. Or consult the documentation for the stepper motor. The motor needs time to turn. If your delay is too short, the current causes the motor to go back before it had time to move forward, hence the vibration. Not ...


1

On a Pi Zero W it takes just less than half a second for that script to start PWM. I'd guess that the bulk of the delay is due to the Python module imports. To facilitate timing I changed the script to the following. #!/usr/bin/env python import time, sys, random import pigpio pi = pigpio.pi() # connect to local Pi redcolor = 128 bluecolor = 128 ...


1

it's --prefix not -prefix (if you copy-pasted, just remove the - and manually type -- (who hyphens))


1

Making a few assumptions about how everything has been configured, you can essentially just directly extract the contents of a *.deb into the root of the file system. You should never, ever, do this on a system where apt is working properly, but if apt isn't available, here's what you do. BUT FIRST, A WARNING! MANUALLY INSTALLING PACKAGES AS DESCRIBED ...


1

I ran into the same issue. You can solve it without using another library. This is how you do it. def button_callback(button): print('Button {} pressed'.format(button)) GPIO.add_event_detect(button, GPIO.FALLING, callback=lambda x: button_callback(1)) By using the lambda, you are executing an anonymous function which then calls your button_callback ...


1

Install and Configure a VNC and use a mobile or a laptop to control your Raspberry Pi.


1

There are many solutions for this, but the normal way is to define a service for systemd. Create a file /etc/systemd/system/my-service.service with this content: [Unit] Description=My Service [Service] ExecStart=/path/to/my-service [Install] WantedBy=multi-user.target Then execute systemctl enable my-service You program should be executed the next ...


1

Put the command line from your .desktop file into /home/pi/.config/lxsession/LXDE-pi/autostart or /etc/xdg/lxsession/LXDE/autostart, whichever you use on your system. /home/pi/.config./autostart directory doesn't seem to exist or be used on Raspbian.


1

you can use: GPIOSimulator This Raspberry Pi emulator simulates some of the functions used in the RPi.GPIO library (using python). The intention of this library is educational. https://pypi.org/project/GPIOSimulator/


Only top voted, non community-wiki answers of a minimum length are eligible