Bottom Page

Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Executing func() from a different folder
#1
Hi,

I've a test.py containing a func(x) in my /home/pi directory.

I need to execute the func(x) from /var/www/html directory with the code "python3 test 0". Said code works within the pi directory but not from outside of it.

I've given the www-data group permissinon to test.py but cannot solve the path '/home/pi' issue.

Any help is appreciated.
You like this post
Quote
#2
Did you also give permissions for the /home/pi directory?

Also do you need to run it exactly with this line?
python3 test 0
You should specify the path:
python3 /home/pi/test.py 0
You like this post
Quote
#3
Thanks. Not sure if it's the right way but I solved my issue by creating a local file point to the original located in a different folder as such:

#!/usr/bin/env python

import sys
sys.path.insert(0, '/home/pi/.')

from gpio import ledsOn

if __name__ == '__main__':
  n = int(sys.argv[1])
  print(ledsOn(n))
You like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Problems parsing /proc folder anddontyoucomebacknomore 2 118 Mar-06-2019, 09:16 PM
Last Post: DeaD_EyE
  Executing python script from SQL Server agent job getting error msavoy 1 117 Feb-15-2019, 08:37 PM
Last Post: Larz60+
  Accessing Files In A Folder asilverg 1 90 Feb-15-2019, 08:08 AM
Last Post: buran
  Delete directories in folder is not working after folder is updated asheru93 2 91 Feb-13-2019, 12:37 PM
Last Post: asheru93
  Error executing Jupyter command 'notebook': [Errno 'jupyter-notebook' not found] 2 Newtopython123 8 8,205 Feb-09-2019, 02:05 PM
Last Post: rudtj5592
  Correct number wrong position func. albry 5 270 Jan-11-2019, 04:01 PM
Last Post: Larz60+
  Error when executing pytesseract to get the text from image bvdinesh 2 425 Jan-06-2019, 05:28 AM
Last Post: bvdinesh
  if-elif-else statement not executing laila1a 4 182 Jan-05-2019, 02:22 PM
Last Post: buran
  Executing 2 lines at the same time SheeppOSU 2 198 Dec-22-2018, 05:16 AM
Last Post: Gribouillis
  python script cant find folder where files are kept Shameendra 2 270 Nov-23-2018, 04:46 PM
Last Post: Shameendra

Forum Jump:


Users browsing this thread: 1 Guest(s)