Questions tagged [python]

Python is a general-purpose, dynamically typed, object-oriented high-level programming language. Interpreters for versions 3.x and 2.x come installed on the Raspberry Pi's most popular operating system distributions.

Filter by
Sorted by
Tagged with
0
votes
1answer
6k views

SIM900 to Raspberry

I've recently bought SIM900 with this module. Connected it to Raspberry Pi - GND, 5V, RX-TX, TX-RX. I'm using following code to test it (found on web): #! /usr/bin/env python import argparse from ...
0
votes
2answers
1k views

pylirc returns none all the time

I'm trying to write simple IR receiver code using pylirc in python but the function Pylirc.nextcode(1) always returns None! I ran a test and everything is good, the terminal and the shell in python ...
-1
votes
2answers
93 views

I don't know where to start [closed]

I am completely new to Raspberry Pi and have started from basically no knowledge. My end goal is to make a synth or drum machine. My problem is that I attempt to start learning something like how to ...
-1
votes
1answer
2k views

How to make application run from python code Raspbian

I have made 2 games, one is pong (using Pygame), and the other one is a text-based quiz. These codes I have made using Python 2.7.1 on Windows laptop. My question is how can I run it on the Pi (which ...
-1
votes
1answer
2k views

How do In open IDLE?

I want to make the whac-a-block on Minecraft Pi. It says I need to use IDLE, but I don't know how to get to it. Please help.
-1
votes
2answers
189 views

Control motors and servos simultaneously (Python)

I have a Raspberry Pi 2B+ and some knowledge of Python. I need to control a DC motor, two servos and a LED simultaneously. The requirements are: Must control two servos, a LED and at least 1 DC ...
-1
votes
1answer
361 views

Unable to capture faces “y is not defined”

I tried removing gray[y:y+h,x:x+w] in imwrite line and the code works amazing but as soon as I add this [y:y+h,x:x+w] it says: y is not defined. I just don't understand how can this error message!!! ...
-1
votes
1answer
50 views

RASPBERRY PI Error Python GUI : “no display name and no $DISPLAY environment variable”

Hi guys I want to create a basic GUI with TKinter. This is my code from tkinter import* import tkinter.font win =Tk() win.title("Test") myFont = tkinter.font.Font( family = 'Helvetica', size = 12, ...
-1
votes
2answers
69 views

How to receive an measurement via RaspberryPi GPIO

Existing codebase being written in python, now requires attaching a new device. Purpose of that device will be to measure analog angle, convert to some format of a number and send it to rpi via some ...
-1
votes
1answer
49 views

Python script not accepting import function

I've been writing a simple python script, and I import the GPIO library, and the time library. I have the following code. print()'Importing GPIO library' import RPi.GPIO as GPIO print()"Importing ...
-1
votes
1answer
42 views

Connecting to the Python server script on the Raspberry Pi over the internet

My application is simple, I want to create a Python server script on my Raspberry Pi and should be able to send a message to my server from internet. My end goal is to control the Raspberry Pi GPIO ...
-1
votes
1answer
258 views

Can you connect (bridge) two GPIO pins over software?

I am trying to bridge two GPIO pins on my RPI so that they will be physically connected. What I mean by this is that if I put current into one it will come out of the other pin depending on wether ...
-1
votes
1answer
249 views

How to make yandex translator api work with raspberry pi

I want to make a python script such that it takes english text from a normal txt file and convert it into another language and store the output in seperate txt file. I have a RPI 3B I have a text ...
-1
votes
1answer
11k views

I'm trying to add a variable but it says 'Invalid Syntax'. What do I do? [closed]

Below is my code which I am using to help me do my mathematics homework. When I run it, I get an 'invalid syntax' message with the variable 'y1' highlighted (look below for which one). I was ...
-1
votes
2answers
2k views

Use if then with GPIO.output(12,False)

I'm working on an automation program with a remote. The remote needs the button to be turned off then on. I have a web service but it can only send the on signal and not the off signal. I want to make ...
-1
votes
1answer
2k views

Read C output in Python [closed]

I'm building a logger to measure temperature and humidity. It's my first Raspberry Pi project. I followed these instructions. The logger runs fine, but I would like to do some things a little ...
-1
votes
1answer
80 views

How and in what language can you create this very little script so it works for Raspberry Pi 3?

I have bought a Raspberry Pi 3 but I cannot run .exe on it (i got a self made script on Windows but it doesn't work for Raspberry). What I want is open browser, press f5 button, loop Can you please ...
-1
votes
1answer
621 views

how to control robot arm with servos by potentiometer

i bought a robot arm consist of 6 servos, is there a possibility to control the servos with potentiometer as the potentiometer moves the servo moves, i wont be using any HAT. thanks
-1
votes
1answer
359 views

Geting errors with c++ using opencv on raspberry Pi

For Face Recognition using raspberry Pi with opencv. I have tried using C++ code which is failing to include the opencv files. Please comment any python code for face recognition using opencv.
-1
votes
1answer
1k views

serial port problem

find a solution about run python program getting error simple program import serial ser =serial.serial ("dev/ttyAMA0",baudrate = 9600) ser.write("code") ser.close() error attributeerror 'module' ...
-1
votes
1answer
904 views

how to autorun a python program in raspberry pi when power supply is ON

how to autorun a python program in raspberry pi when power supply is ON. we followed the link https://www.youtube.com/watch?v=8iU9TnYFOV0 but it is not working
-1
votes
1answer
322 views

How I put a bytearray in python? [closed]

I tried to solve a TypeError:bytearray out of range in diferents forms but I fail fixing this. Someone knows how I put a bytearray with 900000 bytes in python?
-1
votes
1answer
144 views

Dynamically set a timer for a GPIO event? — Using Flask + RPi to control a shop fan

I have a big fan in my shop that I can control via a quick and dirty Flask API i wrote that runs on the pi that controls my fan. I have a web app on my main server (also Flask) that I use to control ...
-1
votes
2answers
4k views

How to run python file from php script [closed]

I have all files placed under var/www/html folder. When I click my button on web page the php file must run the python file and give the ouput at the GPIO pins. But nothing is happening so. Anybody ...
-1
votes
2answers
3k views

insert sensor data in mysql to python [duplicate]

Hello I want to insert sensor data in mysql to python. My sensor is connected to arduino and it sends sensor data to raspberry pi via bluetooth. Raspberry pi receives sensor data to python code. This ...
-1
votes
1answer
792 views

No module named 'mpd'

I started a project at school and I have to make an MP3 player using Python and mpd. I tried installing mpd by running: sudo apt-get install mpd and sudo apt-get install mpd mpc in the terminal. ...
-1
votes
1answer
34 views

Import picture from internet [closed]

I am working on a project that will take an image[s] from an online webcam such as this and then be able to apply some edge detection and motion detection. I have the edge and motion detection running ...
-1
votes
1answer
31 views

Variables dont get initialized [closed]

i am programming a GUI with Qt5 that uses 4 buttons that turn a stepper motor. I just took this setup i found on the internet. Here is my code: from PyQt5 import QtCore, QtGui, QtWidgets from time ...
-1
votes
1answer
133 views

Why does my Python scripts fail to run at boot? [duplicate]

I have a number of sensors connected to my pi 3 and i put the python scripts (7 of them) that starts the sensors at boot in the /etc/profile/ folder.. Of the 7 scripts, i noticed that only the scripts ...
-1
votes
1answer
75 views

Weather Logger Not Working?

When I run my code for my sense hat weather station it outputs the error: File "/home/pi/weather_script.py", line 17 humidity = sense.get_humidity() ^ IndentationError: unexpected indent Here ...
-1
votes
1answer
150 views

Porting Python code to RPi

I would like to port my script, that is great on desktop, to RPi. It is a general question, but just for an example I show my first lines: from http.server import BaseHTTPRequestHandler,HTTPServer ...
-1
votes
1answer
1k views

How to kill python program + cleanup GPIO when button pressed

I'm planning to make a car robot with RPi. I have a python script named 'abc.py', and I'd like to kill the python program and cleanup GPIOs used in abc.py when a button connected to GPIO is pressed. ...
-1
votes
1answer
3k views

How to read from multiplexer with python I2C

Based on the following links: https://forums.adafruit.com/viewtopic.php?f=19&t=83918&p=541562&hilit=TCA9548A#p541562 https://github.com/kizniche/Mycodo/issues/43#issuecomment-156718451 I ...
-1
votes
1answer
518 views

HelloWorld web.py doesn't work

I've seen web.py recommended in some places as a simple python web framework that I could use in my raspberry, so I went ahead and installed it via PIP (sudo pip install web.py). But when I try to ...
-1
votes
2answers
1k views

Tkinter on linux start up

I put a python Tkinter (GUI library) program on startup (/etc/profile) for my Raspberry Pi Linux and the program just has a label. Now i restart my raspberry pi and it's on my screen without any close ...
-1
votes
1answer
932 views

Accessing YUV data in openCV on the RPi [duplicate]

I came across thisquestion and answer which said how to get a numpy array from raspicam, using the PiYUVAnalysis class. I can output the array itself, But i do not know how to view the array as an ...
-1
votes
2answers
528 views

Glade UI Python serial read loop

I'm writing a python program to monitor for serial activity, and when there is serial activity, to increment a number. When inside the while loop, no other functions will work and I can't modify the ...
-1
votes
1answer
279 views

Raspberry-pi mqttc.publish() to node red overflowing after 20 entries

I am using my python code to publish messages to node-red via mqttc. The problem is after 20 mqttc publish,the data is not getting published to nodered. Here is the python code i used for posting to ...
-1
votes
1answer
872 views

Could not find driver when I trying to display my PHP

After going through a few tutorials of displaying data to php from python and my sqlite database, I keep getting this error and don't know how to fix it. I'm in need of urgent help. Error Message ...
-1
votes
0answers
9 views

pocketsphinx.c - Writing raw audio file - segmentation fault

I am working on a smart home system project that uses speech recognition. We have 2 raspberry pi devices. The source code, written in python, works perfectly on one of them but crashes on the other ...
-1
votes
1answer
27 views

One coil is always active on my stepper motor(ULN2003)

When I startup my pi or stop my script, the led on the ULN2003 lights up and stays. That means that one coil is active and the motor is heating up. At the end of my script I introduced a few lines of ...
-1
votes
1answer
44 views

Creating a Day Counter

Does any one know the best way for me to make my PI count the days since an action was performed and display the value every day, I basically want my pi display to tell me how many days have passed ...
-1
votes
1answer
164 views

Unable to run python script on boot

I wrote a script for object detection and if I establish ssh connection to Raspberry Pi and run it from console, everything works fine. As I would like to start the script automatically on boot, I ...
-1
votes
2answers
520 views

How to run a python program from a bash script on startup?

I have a python script that is located at /etc/testscripts/WebServer. I call this usually from the command line by calling sudo python3.6 /etc/testscripts/WebServer. I have a bash script that looks ...
-1
votes
1answer
834 views

How to remove the kill prompt of a python script?

I have a python script that uses Tkinter, the quit button I have implemented pops up a prompt on the python shell after pressing it, which it didn't do on Windows when I wrote the code and tested it. ...
-1
votes
1answer
221 views

raspberrypi - on boot not running my infinite python script?

I have a Python script, which needs to run 24/7 to use GPIO high/low. So on boot i wanted it to run as below. But it never works to run python script on other hand it does create /tmp/test file? How ...
-1
votes
1answer
395 views

How could I use Wit.ai to get speech to text on my webpage running python script

I want the speech to be recorded by raspberry, send it to wit.ai and then get the response on my page(wich is actually the .py script and according to which I could run my conditions). Actually its ...
-1
votes
1answer
38 views

Multiple circuit on raspberry [closed]

Can I create two circuit on one raspberry? I want to create automated watering system for my home plants. There will be two components in this system 1) water pump controlled through Relay system 2) ...
-1
votes
1answer
873 views

How I can use a barcode scanner and PHP/MySQL to run a database? [closed]

I am currently trying the following with the help of a Raspberry Pi: Barcode scanner scans barcode (connected to the Raspberry Pi via USB Port) (via Python?) A hidden form is filled in The user only ...
-1
votes
1answer
81 views

RPi corrupting one SD card a week

I have a model 3 running some python code as a service. It's never on for more than 30 minutes at a time and is maybe used once a day. However, when I do use it, it is often powered on and off ...