Using a imported module in python via pache results in permission denied error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Using a imported module in python via pache results in permission denied error (/thread-12551.html) |
Using a imported module in python via pache results in permission denied error - zooitje - Aug-30-2018 I'm trying to use a imported module (pylightning) in a python script that runs using apache under user www-data. The script gives a permission error when run via apache as user www-data: File "/usr/local/lib/python3.4/dist-packages/lightning/lightning.py", line 69, in call sock.connect(self.socket_path) PermissionError: [Errno 13] Permission deniedTo fix this I have intensively searched and found i needed to reinstall the module as www-data user: sudo pip3 uninstall pylightning sudo -H -u www-data pip3 install pylightningThe script still runs smoothly from the CLI as regular user: $python3 index.py Content-Type: text/html <html><body> etc...But from apache (through a browser or from the command line as user www-data) still gives the same error: $sudo -u www-data python3 /var/www/html/index.py Content-Type: text/html <html><body> Traceback (most recent call last): File "/var/www/html/index.py", line 29, in <module> print(rpc_interface.listpeers()) File "/usr/local/lib/python3.4/dist-packages/lightning/lightning.py", line 345, in listpeers return self.call("listpeers", payload) File "/usr/local/lib/python3.4/dist-packages/lightning/lightning.py", line 69, in call sock.connect(self.socket_path) PermissionError: [Errno 13] Permission deniedAnyone has any idea here? Script source: #!/usr/bin/env python3 import hashlib from lightning.lightning import LightningRpc rpc_interface = LightningRpc("/home/pi/.lightning/lightning-rpc") print ("Content-Type: text/html\n\n"); print ("</body></html>asd"); print(rpc_interface.listpeers()) RE: Using a imported module in python via pache results in permission denied error - zooitje - Aug-30-2018 solved! permissions on ...../lightning-rpc and all higher folders were not set for www-data access. now it works this thead can be closed |