Python Forum
Python in Linux environment on RPI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python in Linux environment on RPI
#10
you need to put the save in the thread run method.
There is nothing that is communicating with the thread, so your write never receives any data.
And while at it, move the open there as well, and use the with open(...) as f:
so in the end run will look like (or similar to as I have not tested):
   def run(self):
       global gpsd
       while gpsp.running:
           with open(locations.csv","w") as f:
               gpsd.next()
               f.write('{}, {}\n'.format(gpsd.fix.longitude, gpsd.fix.latitude))
               # print (gpsd.fix.longitude)
               # print (gpsd.fix.latitude)
Reply


Messages In This Thread
Python in Linux environment on RPI - by kendias - Jun-02-2017, 09:03 PM
RE: Python in Linux environment on RPI - by kendias - Jun-03-2017, 01:59 AM
RE: Python in Linux environment on RPI - by wavic - Jun-03-2017, 04:17 AM
RE: Python in Linux environment on RPI - by kendias - Jun-03-2017, 02:29 PM
RE: Python in Linux environment on RPI - by nilamo - Jun-03-2017, 03:05 PM
RE: Python in Linux environment on RPI - by Ofnuts - Jun-04-2017, 07:54 PM
RE: Python in Linux environment on RPI - by kendias - Jun-06-2017, 01:19 AM
RE: Python in Linux environment on RPI - by Larz60+ - Jun-06-2017, 02:39 AM
RE: Python in Linux environment on RPI - by kendias - Jun-06-2017, 12:56 PM
RE: Python in Linux environment on RPI - by Larz60+ - Jun-06-2017, 05:57 PM
RE: Python in Linux environment on RPI - by kendias - Jun-06-2017, 06:53 PM
RE: Python in Linux environment on RPI - by Larz60+ - Jun-06-2017, 08:21 PM
RE: Python in Linux environment on RPI - by kendias - Jun-06-2017, 09:17 PM
RE: Python in Linux environment on RPI - by Larz60+ - Jun-06-2017, 10:12 PM
RE: Python in Linux environment on RPI - by kendias - Jun-06-2017, 10:42 PM
RE: Python in Linux environment on RPI - by Larz60+ - Jun-06-2017, 10:58 PM
RE: Python in Linux environment on RPI - by Larz60+ - Sep-03-2020, 03:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is possible to run the python command to call python script on linux? cuten222 6 813 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  Installing python packages in a virtual environment Led_Zeppelin 1 801 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 2,345 May-10-2023, 02:13 PM
Last Post: Calab
  Python development environment standenman 3 1,696 May-04-2023, 07:24 PM
Last Post: snippsat
  Python Scripting Environment jpotter0 1 1,779 Nov-19-2022, 03:07 PM
Last Post: snippsat
  How to use a variable in linux command in python code? ilknurg 2 1,634 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  How do I link the virtual environment of that project to the 3.9.2 version of python? Bryant11 1 1,408 Feb-26-2022, 11:15 AM
Last Post: Larz60+
  Python syntax in Linux St0rmcr0w 2 54,060 Jul-29-2021, 01:40 PM
Last Post: snippsat
  VS Code debugger using wrong Python environment topfox 0 2,543 Jun-09-2021, 10:01 AM
Last Post: topfox
  Login to NordVPN on Linux with python script AGreenPig 2 6,055 Feb-09-2021, 10:44 AM
Last Post: AGreenPig

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020