uafgeotools / mtuq

moment tensor uncertainty quantification
BSD 2-Clause "Simplified" License
65 stars 22 forks source link

ImportError during pip installation of mtuq #253

Open jwebster-LANL opened 4 months ago

jwebster-LANL commented 4 months ago

I searched mtuq's issues and didn't find this, but I'm not the only person who has had this issue, as other colleagues have as well. This popped up while installing mtuq via pip using the command

>> pip install https://github.com/uafgeotools/mtuq.git

or through a conda installation yml file:

- pip:
    - git+https://github.com/uafgeotools/mtuq.git

pip will create a folder in the file system's /tmp folder and will try to compile things there. If, however, the noexec flag is set on that folder (usually when mounted using the /etc/fstab file), the installer will return an ImportError that looks something like:

ImportError: /tmp/pip-build-env-ot0llisc/overlay/lib/python3.11/site-packages/numpy/core/[_multiarray_umath.cpython-311-x86_64-linux-gnu.so](https://urldefense.com/v3/__http://_multiarray_umath.cpython-311-x86_64-linux-gnu.so__;!!Bt8fGhp8LhKGRg!HKp84Ietwm74DPIDbrML2aU3dfpZ9ok60WBJ-mNvAZb-yv3fBvisAc3dx1kA40QvLlz9r7U3u0B08civ5-4sogmi5dbc0M0$): failed to map segment from shared object

There are at least two ways to fix this, the best one seems to be to set the TMPDIR environment variable to point to a directory that has doesn't have the noexec flag set. I use the tmp directory in my home folder...

>> export TMPDIR=~/tmp/

and that should allow the pip installation of mtuq to work.

Alternatively you can remove the noexec flag from where the /tmp folder is mounted in /etc/fstab, but that can be a security issue. Generally you don't want things in /tmp to be executable.

I think TMPDIR could be set at the start of the setup.py script and unset after it's finished, but I'm not sure that's a good approach.

Perhaps a note could be put in the troubleshooting section of the documentation explaining this and the solution? It's happened to a few people I know, and the solution isn't obvious for most people.

We are using various versions of RedHat Enterprise linux btw.

Thanks

rmodrak commented 4 months ago

Thanks for this report. A lot related forum discussion as you were saying

https://github.com/pypa/pip/issues/4462

https://stackoverflow.com/questions/67115835/how-to-change-pip-unpacking-folder