If you want to use pymol as an import in your backend code:
You could create a virtual environment based on the python3
version that PyMOL ships. As Matteo says, it's a separate python3
that gets installed on your system.
The way to find which one is "PyMol python"(as opposed to your other pythons) is to open PyMOL the GUI and execute import sys; print(sys.executable)
. Props to Maximilian Peters.
Now that you know where the pymol's python3 exec is you can create a virtualenv
based on it:
virtualenv --python="/usr/bin/python3"
.
In my case it happened to be /usr/bin/python
but yours might be different.
Now you can install packages into this virtual environment and import pymol
to invoke its functionality alongside your regular python/django/flask/numpy code or whatever.
If you want to use it as a module, follow https://pymolwiki.org/index.php/Linux_Install and add the $PYMOL_PATH/modules/
folder to your python path (export PYTHONPATH="$PYTHONPATH:$PYMOL_PATH/modules/:"
). So you can put your pymol in a completely different location so logn as the python that runs your main scritp/application has the modules
files on path.
Paraphrasing Leandro from the forum:
python3 setup.py build install --home=path_to_pymol/
--install-lib=path_to_pymol/modules/ --install-scripts=path_to_pymol/
The part you are interested in is the modules.
In addition, you need to add `path_to_pymol/modules/` to your python
paths. You can add these to the .bashrc
file:
export PYMOL_PATH=path_to_pymol/
export PYTHONPATH=$PYTHONPATH:$PYMOL_PATH/modules: