Agi python script execution error, Permission denied and No such file or directory

Hello, everyone. Please help me!

dialing plan:
image

The script is as follows:Script first line #! / home/PI/miniforge3 / envs/freePbx/bin/python3 is I use conda create environment directory

file permission:
image

When a text message is received, the sms dialing plan is triggered to run the script, and an error is reported:

When I change the first line of the script to #! /usr/bin/env python3, then no error will be reported, but the log message is not output and the script is not running

If you have changed the environment directory permissions
sudo chmod -R a+X /home/pi/miniforge3/envs/freePbx
sudo chmod -R a+r /home/pi/miniforge3/envs/freePbx
No such file or directory will be reported:

After rebooting the PI using sudo reboot, it was Permission denied again

In addition, I am through [PBX] FreePBX for the Raspberry Pi - VOIP Tech Chat | DSLReports Forums to install asterisk + freepbx, I haven’t figure out how to modify the configuration, In order to run asterisk as root when the Raspberry PI starts

Change the first line of the script to #! /usr/bin/env python3, the error is not reported, the script did not run because of the Window newline (CRLF, \r\n), not Unix-style newline (LF, \n), The only problem is that if the first line is changed to a python environment created by conda, the Permission denied will be displayed. How do I set the permission so that I can restart the Raspberry PI without having to set it again

I thought Conda was a Windows thing: there shouldn’t be any need to use it on Linux.

On Linux, I would recommend you stick to the system Python installation (/usr/bin/python3). If you need some small number of additional Python packages that are not available in the standard repos, you can install them into /usr/local/lib/pythonver/dist-packages/ with pip. Anything more complicated that that might require virtualenv.

And yes, fix those line endings as well.

After I restarted Raspberry PI, agi won’t work again, I use #! /usr/bin/env python, and pip install pyyaml, I still can not run, there is no error, I directly execute./sms_handler.py can run, but the agi command can not run, there is no error in the log, how do I install this module,I guess because pyyaml is not installed in the asterisk environment, how do I install it?

When Asterisk spawns your AGI process, it sets stdout and stderr to /dev/null. You can restore a more useful stderr destination by putting something like

log = open("/tmp/agi_try.log", "w")
os.dup2(log.fileno(), 2)
log.close()

near the top of your script.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.