My filesystem is Ubuntu.
While running code in python, using venv, I got the following error message:
Traceback (most recent call last):
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/_core/__init__.py", line 23, in <module>
from . import multiarray
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/_core/multiarray.py", line 10, in <module>
from . import overrides
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/_core/overrides.py", line 8, in <module>
from numpy._core._multiarray_umath import (
ImportError: /home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/_core/_multiarray_umath.cpython-310-x86_64-linux-gnu.so: failed to map segment from shared object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/__init__.py", line 114, in <module>
from numpy.__config__ import show as show_config
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/__config__.py", line 4, in <module>
from numpy._core._multiarray_umath import (
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/_core/__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/bin/python3"
* The NumPy version is: "2.0.0"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/_core/_multiarray_umath.cpython-310-x86_64-linux-gnu.so: failed to map segment from shared object
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/stokes_flow_cylindric_metric.py", line 10, in <module>
import numpy as np
File "/home/jan/mounted/publications/sea_snow/fem_advection_diffusion/venv/lib/python3.10/site-packages/numpy/__init__.py", line 119, in <module>
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
I have installed the necessary packages. I have got good pip version and I have tried reinstalling various stuff such as pip, venv and even system.
The root of the problem was in unusual file system I am using. The location where I have tried to setup venv was another partition with ntfs, instead of partition with ext4.
So the problem was in permissions on this partition - mounting was incorrect.
After mountig with exec via fstab, everything was working fine.
Edit 1: Previously mounting via fstab was as follows:
UUID=E648EDF448EDC381 /home/jan/mounted ntfs auto,users,uid=1000,gid=1000,dmask=027,fmask=137,umask=000,nls=utf8 0 0
It worked fine, but it mounted the partition as a root and I think this caused the problem. Now fstab looks like this:
UUID=E648EDF448EDC381 /home/jan/mounted ntfs-3g defaults,umask=000,uid=jan,gid=jan,nofail 0 0
And everything is ok.