nomad icon indicating copy to clipboard operation
nomad copied to clipboard

Install PyNomad in virtual environment

Open lucagrementieri opened this issue 2 years ago • 3 comments

The current installation instructions make very hard to install PyNomad in virtual enviroment, in fact the --user option in the line COMMAND python setup_PyNomad.py ${CMAKE_BINARY_DIR} ${NOMAD_VERSION} install inside interfaces/PyNomad/CMakeLists.txt overwrite the default setting of a virtual environment.

A separate parameter PYTHON_DIR defined in CMake could allow the user to specify the correct Python location, otherwise the --user flag could be removed to let the system the best location by itself.

Is there a way to install PyNomad in a virtual environment with the current code?

lucagrementieri avatar Dec 29 '22 11:12 lucagrementieri

To answer your question: If you need that, do not build the Python module with the rest of the project.

  1. Suppose we are dealing with the release 4.3.1.

  2. Follow the instructions for building and installing Nomad.

  3. Suppose it was built in /some/path/nomad-v.4.3.1 and installed into /some/path/nomad-v.4.3.1/build/release. Adjust these paths below to fit your situation.

  4. Navigate to /some/path/nomad-v.4.3.1/interfaces/PyNomad

  5. Compile the module manually. Suppose the root of the virtual environment is located at /another/path/to/venv. Execute

/another/path/to/venv/bin/python setup_PyNomad.py /tmp/nomad-v.4.3.1/build/release "4.3.1" build_ext --inplace

to compile the module. Please note that you'll need Cython available within that environment.

  1. Once the module is compiled, execute
/another/path/to/venv/bin/python setup_PyNomad.py /tmp/nomad-v.4.3.1/build/release 4.3.1 install --

to install it within the virtual environment.

jan-provaznik avatar Dec 29 '22 15:12 jan-provaznik

Thanks for the suggestion. It works for me in a virtual environment.

ctribes avatar Jan 09 '23 14:01 ctribes

I would just like to point out that in my case, I had to do this: export LD_LIBRARY_PATH=$NOMAD_HOME/build/release/lib64/:$LD_LIBRARY_PATH Otherwise I got the following error:

$ python runTest_BlockEval.py 
Traceback (most recent call last):
  File "/.../.../runTest_BlockEval.py", line 1, in <module>
    import PyNomad
ImportError: libnomadUtils.so.4.3: cannot open shared object file: No such file or directory

davidmurray avatar Apr 17 '23 19:04 davidmurray