Python Script no longer echos output?

Hi all,
was running a Python Script successfully up till yesterday. Echoing output to cli.
stopped the script and restarted and now script is no longer echoing output and is no longer working or displaying any errors?

Have tried Thony to debug says everything is correct?

Has anyone come across this?

I am running Raspberry Pi Zero and PiicDev_BME280

3 Likes

Might be worth trying a basic script, without any other code

print("Hello World")

4 Likes

Hi Phil,

Were you able to get the script to do a basic print() command as Gramo has suggested? This would isolate the PiicoDev sensor setup and hardware from the equation and might help pinpoint what’s changed.

3 Likes

Hi Trent and @Gramo. the Piico Sensor is working fine. This script is working correctly.
However, the other script that I wrote was echoing correctly and this has just stopped working.
You can run the script, i.e. python3 script.py and this gives no echo and or errors?
strange.

2 Likes

Hi Phil,

Does a totally new script with just hello world echo? Or does only your custom script not return the echo?

If an otherwise blank script returns the echo then we’ll know that it’s something in your script.py which is causing the strange behaviour, even if other functions of the script are still performing their jobs normally.

3 Likes

Hi Trent,

the affected script is pi@pi0w-weather-stn-herm:~/Weather $ python3 vk5rkw_weather_station4.py
testhello.py echos out Hello World as per @Gramo

pi@pi0w-weather-stn-herm:~/Weather python3 vk5rkw_weather_station4.py pi@pi0w-weather-stn-herm:~/Weather python3 testhello.py
Hello World

PiicoDev_BME280 script works fine

pi@pi0w-weather-stn-herm:~/PiicoDev $ python3 piicodev_to_mqtt5.py
30.17 °C 957.8265234375 hPa 26.607421875 % RH
sending {sensor data} to server
30.16 °C 957.7457421875 hPa 26.4169921875 % RH

vk5rkw_weather_station4.py can be found here:
PhilKern65/aprs-weather: Weather data using a PiicoDev_BME280 sensor and Raspberry Pi Zero and transmit weather data via APRS (github.com)

Cheers in advance

2 Likes

Python is an interpreted language; each line of code is interpreted and then run. Perhaps add print statements with basic debug text, starting at line 1 and every so often as you feel appropriate.

Don’t go overboard first time around, you’ll soon iterate toward the issue and find out which line of code is the problem.

When a line of code fails you get an error on the terminal. Interesting that you don’t, so it’s more likely an infinite loop or blocking call never completes.

Good luck and let me know how you go!

5 Likes

Thanks, will check and advise.

Phil

2 Likes

Hi @Gramo…After many hours of trial and error, I simply just started again.
Its working, but needs some legacy code removed.

Thanks again.

Phil

6 Likes

Recently I experienced something similar.
I cut and pasted some code from a web page and it did not work as it should.

When I typed in the code it worked ok.

I put it down to some characters in the cut and paste which were hidden in the text display but affected the running of the code. Thonny

When I cut and paste now; I will put it into a simple text editor like the one that comes with Windows 10. Then cut and paste the text from the text editor.

Unsure if this is your problem, but it was confusing at the time.

cheers
Jim

6 Likes

Hi James, from your description it sounds like maybe it’s a space/tab issue.
Some people like to use tabs instead of spaces, visa-versa.

For Python, which is indent sensitive, mixing spaces and tabs should be avoided.
So even if the spacing/tab looks the same, the interpreter does not think so.

Sorry, this probably doesn’t answer the main topic.

1 Like