Я получаю сообщение об ошибке при импорте numpy из приложения Apache mod_wsgi в Fedora 43. Этого не происходит в Rocky Linux 9, рабочем сервере.
app.wsgi:
import sys
sys.path.insert(0, '/var/www/html/test/')
from test import application
test.py:
import numpy
def application(environ, start_response):
status = '200 OK'
output = b'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Журнал ошибок:
mod_wsgi (pid=187553): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=187553): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
ImportError: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 48, in
raise ImportError(msg) from exc
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/troubles ... error.html
Please note and check the following:
* The Python version is: Python3.14 from "/var/www/html/test/venv/bin/python"
* The NumPy version is: "2.3.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 117, in
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.
mod_wsgi (pid=187552): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=187552): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
ImportError: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 48, in
raise ImportError(msg) from exc
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/troubles ... error.html
Please note and check the following:
* The Python version is: Python3.14 from "/var/www/html/test/venv/bin/python"
* The NumPy version is: "2.3.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 117, in
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.
Если я импортирую запросы, это работает. Файл конфигурации сайта Apache, настраивающий виртуальную среду:
ServerName test.local
ErrorLog logs/test-error_log
CustomLog logs/test-access_log combined
WSGIScriptAlias / /var/www/html/test/app.wsgi
WSGIDaemonProcess test processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/html/test/venv
WSGIProcessGroup test
Require all granted
Когда я изменяю приведенную выше конфигурацию, чтобы не устанавливать переменную python-home, используя таким образом системную среду, ошибка меняется на
mod_wsgi (pid=189077): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=189077): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/usr/local/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/usr/local/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
RuntimeError: CPU dispatcher tracer already initlized
mod_wsgi (pid=189076): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=189076): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/usr/local/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/usr/local/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
RuntimeError: CPU dispatcher tracer already initlized
Импорт numpy как из venv, так и из системного (от имени root) интерпретатора командной строки работает
(venv) cpn@d3:/var/www/html/test$ python
Python 3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
root@d3:/etc/httpd/conf.d# python
Python 3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
Есть идеи?
Как предложил @Nick Odell:
(venv) cpn@d3:/var/www/html/test$ python -c 'import sys; print(sys.prefix)'
/var/www/html/test/venv
Подробнее здесь: https://stackoverflow.com/questions/798 ... -fedora-43
Ошибка импорта Numpy в приложении mod_wsgi в Fedora 43 ⇐ Python
Программы на Python
-
Anonymous
1764607211
Anonymous
Я получаю сообщение об ошибке при импорте numpy из приложения Apache mod_wsgi в Fedora 43. Этого не происходит в Rocky Linux 9, рабочем сервере.
app.wsgi:
import sys
sys.path.insert(0, '/var/www/html/test/')
from test import application
test.py:
import numpy
def application(environ, start_response):
status = '200 OK'
output = b'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Журнал ошибок:
mod_wsgi (pid=187553): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=187553): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
ImportError: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 48, in
raise ImportError(msg) from exc
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.14 from "/var/www/html/test/venv/bin/python"
* The NumPy version is: "2.3.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 117, in
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.
mod_wsgi (pid=187552): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=187552): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
ImportError: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 48, in
raise ImportError(msg) from exc
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.14 from "/var/www/html/test/venv/bin/python"
* The NumPy version is: "2.3.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /var/www/html/test/venv/lib64/python3.14/site-packages/numpy/_core/_multiarray_umath.cpython-314-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 "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/var/www/html/test/venv/lib64/python3.14/site-packages/numpy/__init__.py", line 117, in
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.
Если я импортирую запросы, это работает. Файл конфигурации сайта Apache, настраивающий виртуальную среду:
ServerName test.local
ErrorLog logs/test-error_log
CustomLog logs/test-access_log combined
WSGIScriptAlias / /var/www/html/test/app.wsgi
WSGIDaemonProcess test processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/html/test/venv
WSGIProcessGroup test
Require all granted
Когда я изменяю приведенную выше конфигурацию, чтобы не устанавливать переменную python-home, используя таким образом системную среду, ошибка меняется на
mod_wsgi (pid=189077): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=189077): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/usr/local/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/usr/local/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
RuntimeError: CPU dispatcher tracer already initlized
mod_wsgi (pid=189076): Failed to exec Python script file '/var/www/html/test/app.wsgi'.
mod_wsgi (pid=189076): Exception occurred processing WSGI script '/var/www/html/test/app.wsgi'.
Traceback (most recent call last):
File "/var/www/html/test/app.wsgi", line 3, in
from test import application
File "/var/www/html/test/test.py", line 1, in
import numpy
File "/usr/local/lib64/python3.14/site-packages/numpy/__init__.py", line 112, in
from numpy.__config__ import show_config
File "/usr/local/lib64/python3.14/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
......
)
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/__init__.py", line 22, in
from . import multiarray
File "/usr/local/lib64/python3.14/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
RuntimeError: CPU dispatcher tracer already initlized
Импорт numpy как из venv, так и из системного (от имени root) интерпретатора командной строки работает
(venv) cpn@d3:/var/www/html/test$ python
Python 3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
root@d3:/etc/httpd/conf.d# python
Python 3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
Есть идеи?
Как предложил @Nick Odell:
(venv) cpn@d3:/var/www/html/test$ python -c 'import sys; print(sys.prefix)'
/var/www/html/test/venv
Подробнее здесь: [url]https://stackoverflow.com/questions/79834996/numpy-importing-error-in-mod-wsgi-app-on-fedora-43[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия