JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.47k stars 187 forks source link

pyimport("pyvista") problem #920

Open zhang-rite opened 3 years ago

zhang-rite commented 3 years ago

Description

I encounter a problem that when calling PyVista through PyCall by using PyCall; pv = pyimport("pyvista"), whereas there is no problem when directly use pyvista in python. I do use the same conda env for both python and Julia (/lustre/home/.julia/adcme/bin/python). I have tested setting ENV["PYTHON"] or Conda.add way or pip install pyvista==0.30.0rc1 or conda install -c conda-forge pyvista or conda install -c conda-forge xvfbwrapper, then rebuilding PyCall and restarting Julia etc., but the problem remains.

The errors are as below.

The Python package pyvista could not be imported by pyimport. Usually this means
that you did not install pyvista in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

/lustre/home/.julia/adcme/bin/python

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the pyvista module.

One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.

Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia.  As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the pyvista module, you can use `pyimport_conda("pyvista", PKG)`,
where PKG is the Anaconda package that contains the module pyvista,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <class 'ImportError'>
ImportError('libX11.so.6: cannot open shared object file: No such file or directory')
  File "/lustre/home/.julia/adcme/lib/python3.7/site-packages/pyvista/__init__.py", line 11, in <module>
    from pyvista.plotting import *
  File "/lustre/home/.julia/adcme/lib/python3.7/site-packages/pyvista/plotting/__init__.py", line 7, in <module>
    from .helpers import plot, plot_arrows, plot_compare_four, plot_itk
  File "/lustre/home/.julia/adcme/lib/python3.7/site-packages/pyvista/plotting/helpers.py", line 7, in <module>
    from pyvista.utilities import is_pyvista_dataset
  File "/lustre/home/.julia/adcme/lib/python3.7/site-packages/pyvista/utilities/__init__.py", line 2, in <module>
    from .errors import (GPUInfo, Observer, Report,
  File "/lustre/home/.julia/adcme/lib/python3.7/site-packages/pyvista/utilities/errors.py", line 12, in <module>
    from pyvista import _vtk
  File "/lustre/home/.julia/adcme/lib/python3.7/site-packages/pyvista/_vtk.py", line 41, in <module>
    from vtkmodules.vtkRenderingVolumeOpenGL2 import (vtkOpenGLGPUVolumeRayCastMapper,

Stacktrace:
 [1] pyimport(name::String)
   @ PyCall /lustre/home/.julia/packages/PyCall/BD546/src/PyCall.jl:550
 [2] top-level scope
   @ REPL[5]:1

I use Julia through singularity exec julia_latest.sif julia. I am working on an HPC cluster without sudo privilege.

Thanks.

zhang-rite commented 3 years ago

Maybe the problem is due to the lacking of xvfb on the HPC. I am now going to contact the HPC administrator for help.