Reputation: 11
I use python 3.6.9 and asterisk 16.16.0 in Ubuntu 18.04.
If you know about AGI then you probably know about this line
#!/usr/bin/python
or this
#!/usr/bin/env python
if not then don't worry its tells the system to run this script in the Python interpreter.
So as far you know what I can do. but now my question is if I am use virtual environment for python using help of venv package and want defines path of that python environment in my AGI then what should I define.
My virtual environment store in following directory: /home/test/Documents/environments/test_env.
Upvotes: 0
Views: 2790
Reputation: 15247
When you are running ANY agi script in asterisk it will run under asterisk user.
Asterisk user on most systems is limited user and may have no python environment at all.
Best way is create virtual environment for your python and use full path for your python INSIDE venv like /opt/my_virtual_env/bin/python3 in all agi scripts.
Ensure that those path is readable by asterisk user or owned by asterisk user
Upvotes: 0
Reputation: 169
Try adding this path to the $PATH
variable
/home/test/Documents/environments/test_env/bin
This directory contains scripts like activate
, deactivate
etc. which are used for activating and deactivating the virtual env.
Regarding the shebang, #!/usr/bin/env python
should work properly if the virtual env is activated.
Hope this is what you were looking for.
Upvotes: -1