Thank you 😍
Great question! To install Python packages in the mgr/python
folder, you can use the pip
command with the --target
option. This allows you to specify the directory where the packages should be installed. Here's how you can do it:
pip install --target=/path/to/your/iris/mgr/python requests numpy
A second option can be to use a virtual environment, which is a good practice to isolate your Python dependencies. You can create a virtual environment in whatever directory you want, and then install the packages there. After that, you can add the path to the virtual environment's site-packages
directory to the sys.path
in your ObjectScript code.
Here's how you can do it:
# Create a virtual environment
python -m venv /where/you/want/your/venv
# Activate the virtual environment
source /where/you/want/your/venv/bin/activate
# Install the packages you need
pip install requests numpy
Then, in your ObjectScript code, you can add the path to the virtual environment's site-packages
directory:
set sys = ##class(%SYS.Python).Import("sys")
do sys.path.append("/where/you/want/your/venv/lib/pythonX.X/site-packages")
set requests = ##class(%SYS.Python).Import("requests")
An article about this is coming soon, stay tuned!
I also recommend checking this article about Python modules for more details on how to manage Python modules in IRIS.










+1 and for community web site too :)