I’m trying to install pytorch and pytesseract on PSC Bridges and I want to use that on a compute node, running in Jupyter notebook via OnDemand. I’ve installed both packages using the login node and pip install --user pytorch pytesseract
and that installs correctly, but I can’t get it to load the module when I run the Jupyter notebook with OnDemand. We also looked at this blog post that seems to point to part of an answer: https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/
Based on wirawan0’s comment I see the problem now.
Bridges jupyterhub uses a conda environment: /opt/packages/anaconda/anaconda3-5.1.0
If you want to access that environment from the login node you could activate it:
source /opt/packages/anaconda/anaconda3-5.1.0/bin/activate
pip install torch --user
It’s probably more consistent to launch juptyerhub, open a terminal, and then pip install torch --user because that will always use the correct conda environment.
Thanks,
Mark
PS You can see where jupyterhub is loaded from using:
import sys
print (sys.prefix)
My immediate question is: does Jupyter notebook launched by Bridges’ Open OnDemand even support virtual environment? If it does not, then it is not straightforward to “fudge” Jupyter to use virtual environment.
Does the package work correctly in a regular Python environment (not within Jupyter notebook)?
If it does not - what kind of error do you get and when? Does the error occur during import command, or when you use a function from this package?