Using python simpleapi with Ubuntu 20.04

Hi All,

I recently followed the instructions for building from source on Ubuntu 20.04.

Unfortunately I have found that the $BUILD_DIR/lib directory is not populated. When I’ve installed this on 18.x before, this was where the simpleapi module was stored.

Can someone give me a hint as to whether this has been moved / I’m not using the right options when running cmake / it has been missed out of the make file?

Thanks,
Andrew

Some information:

Version:

alister@SCLT118:/opt/Mantid$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

History:

2105  cd /opt/Mantid/
2106  ls ~/mantid/
2107  apt-get install -y   git   g++   clang-format-6.0   cmake   dvipng   doxygen   libtbb-dev   libgoogle-perftools-dev   libboost-all-dev   libpoco-dev   libnexus-dev   libhdf5-dev   libhdf4-dev   libjemalloc-dev   libgsl-dev   liboce-visualization-dev   libmuparser-dev   libssl-dev   libjsoncpp-dev   librdkafka-dev   qtbase5-dev   qttools5-dev   qttools5-dev-tools   libqt5webkit5-dev   libqt5x11extras5-dev   libqt5opengl5-dev   libqscintilla2-qt5-dev   libpython3-dev   ninja-build   python3-setuptools   python3-sip-dev   python3-pyqt5   pyqt5-dev   pyqt5-dev-tools   python3-qtpy   python3-numpy   python3-scipy   python3-sphinx   python3-sphinx-bootstrap-theme   python3-pycifrw   python3-dateutil   python3-matplotlib   python3-qtconsole   python3-h5py   python3-mock   python3-psutil   python3-requests   python3-toml   python3-yaml
2108  sudo apt-get install -y   git   g++   clang-format-6.0   cmake   dvipng   doxygen   libtbb-dev   libgoogle-perftools-dev   libboost-all-dev   libpoco-dev   libnexus-dev   libhdf5-dev   libhdf4-dev   libjemalloc-dev   libgsl-dev   liboce-visualization-dev   libmuparser-dev   libssl-dev   libjsoncpp-dev   librdkafka-dev   qtbase5-dev   qttools5-dev   qttools5-dev-tools   libqt5webkit5-dev   libqt5x11extras5-dev   libqt5opengl5-dev   libqscintilla2-qt5-dev   libpython3-dev   ninja-build   python3-setuptools   python3-sip-dev   python3-pyqt5   pyqt5-dev   pyqt5-dev-tools   python3-qtpy   python3-numpy   python3-scipy   python3-sphinx   python3-sphinx-bootstrap-theme   python3-pycifrw   python3-dateutil   python3-matplotlib   python3-qtconsole   python3-h5py   python3-mock   python3-psutil   python3-requests   python3-toml   python3-yaml
2109  export QT_API=pyqt5
2110  sudo apt install ccache
2111  ccache  --max-size=20G
2112  cmake ~/mantid/ -DENABLE_MANTIDPLOT=OFF
2113  sudo chown alister /opt/Mantid
2114  cmake ~/mantid/ -DENABLE_MANTIDPLOT=OFF

Out of source build dir:

alister@SCLT118:/opt/Mantid$ ls -l
total 272
-rw-r--r--  1 alister alister 58168 Feb  2 17:46 CMakeCache.txt
-rw-r--r--  1 alister alister 14305 Feb  2 17:45 CMakeDoxyfile.in
-rw-r--r--  1 alister alister 19712 Feb  2 17:45 CMakeDoxygenDefaults.cmake
drwxr-xr-x 13 alister alister  4096 Feb  2 17:46 CMakeFiles
-rw-r--r--  1 alister alister   468 Feb  2 17:46 CTestTestfile.cmake
drwxr-xr-x 32 alister alister  4096 Feb  2 17:46 Framework
-rw-r--r--  1 alister alister 67437 Feb  2 17:46 Makefile
drwxr-xr-x  4 alister alister  4096 Feb  2 17:46 PyStoG-download
-rw-r--r--  1 alister alister   480 Feb  2 17:45 StandardTestData_config.cmake
-rw-r--r--  1 alister alister   480 Feb  2 17:45 SystemTestData_config.cmake
drwxr-xr-x  3 alister alister  4096 Feb  2 17:46 Testing
drwxr-xr-x  8 alister alister  4096 Feb  2 17:45 _deps
drwxr-xr-x  3 alister alister  4096 Feb  2 17:46 bin
-rw-r--r--  1 alister alister  4909 Feb  2 17:46 cmake_install.cmake
drwxr-xr-x  3 alister alister  4096 Feb  2 17:46 dev-docs
drwxr-xr-x  3 alister alister  4096 Feb  2 17:46 docs
drwxr-xr-x  7 alister alister  4096 Feb  2 17:45 extern-eigen
-rw-r--r--  1 alister alister  2032 Feb  2 17:45 launch_mantidworkbench.sh.install
drwxr-xr-x  2 alister alister  4096 Feb  2 17:46 lib
-rw-r--r--  1 alister alister    57 Feb  2 17:45 mantid.csh
-rw-r--r--  1 alister alister    48 Feb  2 17:45 mantid.pth.install
-rw-r--r--  1 alister alister    57 Feb  2 17:45 mantid.sh
-rwxr-xr-x  1 alister alister  1716 Feb  2 17:45 mantidpython.install
-rw-r--r--  1 alister alister   350 Feb  2 17:46 mantidworkbenchunstable.desktop.install
-rw-r--r--  1 alister alister  1865 Feb  2 17:45 postinst
-rw-r--r--  1 alister alister  1281 Feb  2 17:45 preinst
-rw-r--r--  1 alister alister  1418 Feb  2 17:45 prerm
drwxr-xr-x  8 alister alister  4096 Feb  2 17:46 qt
drwxr-xr-x  9 alister alister  4096 Feb  2 17:46 scripts
-rwxr-xr-x  1 alister alister  2394 Feb  2 17:46 systemtest

alister@SCLT118:/opt/Mantid$ ls -l bin lib
bin:
total 32
-rwxr-xr-x 1 alister alister  2863 Feb  2 17:45 AddPythonPath.py
-rw-r--r-- 1 alister alister 12382 Feb  2 17:46 Mantid.properties
drwxr-xr-x 2 alister alister  4096 Feb  2 17:45 Testing
-rwxr-xr-x 1 alister alister  2021 Feb  2 17:45 launch_mantidworkbench.sh
-rwxr-xr-x 1 alister alister  1763 Feb  2 17:45 mantidpython

lib:
total 0

We use mantid through other python scripts as detailed in this post

Hi,
This seems to be the same for Ubuntu 18.04 and 20.04, and I don’t think it’s a problem that lib is empty. Adding the build_mantid/bin directory to the PYTHONPATH should be fine.

Tell me if this works for you!

Hi @DanielMurphy22,

Thanks for getting back to me, when I try it on my Ubuntu20.04 machine I get the following:

(fitbenchmarking) alister@SCLT118:~$ echo $PYTHONPATH
/home/alister/fitbenchmarking:/home/alister/cutest/pycutest_cache:/opt/Mantid/lib:/opt/Mantid/bin:
(fitbenchmarking) alister@SCLT118:~$ python
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mantid import simpleapi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'simpleapi' from 'mantid' (unknown location)

It works fine on my Ubuntu18.04 machine (which I installed via the apt instructions rather than from source):

alister@SCLT118:/mnt/c/Users/eel23943$ echo $PYTHONPATH
/home/alister/fitbenchmarking/pycutest_cache::/opt/Mantid/lib:/opt/Mantid/bin:/opt/Mantid/lib:/opt/Mantid/bin
alister@SCLT118:/mnt/c/Users/eel23943$ python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mantid import simpleapi
FrameworkManager-[Notice] Welcome to Mantid 5.1.1
FrameworkManager-[Notice] Please cite: http://dx.doi.org/10.1016/j.nima.2014.07.029 and this release: http://dx.doi.org/10.5286/Software/Mantid5.1.1
GitHubApiHelper-[Warning] Authentication failed and anonymous access refused

GitHubApiHelper-[Warning] Authentication failed and anonymous access refused

GitHubApiHelper-[Warning] Authentication failed and anonymous access refused

DownloadInstrument-[Error] Error in execution of algorithm DownloadInstrument:
DownloadInstrument-[Error] Unable to parse server JSON file "/home/alister/.mantid/instrument/github.json"

I think launching with mantidpython should work. Can you check if mantidpython at /opt/Mantid/bin/mantidpython
or
/usr/local/bin/mantidpython ?

Also I assume you did build after running those cmake lines in your history (with ninja or cmake --build)?

Ahh… I thought I was probably missing something stupid! I guess this falls into the second part of my original q, “I’m not using the right options when running cmake”.

I think I’ve gotten too used to working in python. Thanks for the help, I’ve set that off now.