[tool.poetry]
name = "snaqs"
version = "3.0.0"
description = "A minimal rewrite of Philips' snaqs for DCDC Tx"
authors = ["Freek van Hemert "]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"
pandas = "^2.2.3"
numpy = "^2.2.4"
[tool.poetry.group.dev.dependencies]
jupyterlab = "^4.4.0"
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
]
[tool.poetry.group.test.dependencies]
pytest = "^8.3.5"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Затем я выполняю установку поэзии
Обычно я начинаю тестирование, но, чтобы свести его к минимуму, я открываю оболочку Python3 с помощью Python3. Теперь, когда я импортирую numpy как np, я получаю эту ошибку:
$ python3
Python 3.12.8 (main, Dec 3 2024, 18:42:41) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/_core/__init__.py", line 23, in
from . import multiarray
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/_core/multiarray.py", line 10, in
from . import overrides
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/_core/overrides.py", line 7, in
from numpy._core._multiarray_umath import (
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/__init__.py", line 114, in
from numpy.__config__ import show_config
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/__config__.py", line 4, in
from numpy._core._multiarray_umath import (
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/_core/__init__.py", line 49, in
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/troubles ... error.html
Please note and check the following:
* The Python version is: Python3.12 from "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/bin/python3"
* The NumPy version is: "2.2.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libstdc++.so.6: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/numpy/__init__.py", line 119, 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.
Этот вопрос возникал у меня неоднократно. Возможно, было бы неплохо сказать, что я использую NixOS и установил поэзию, используя этот файл Shell.nix:
{ pkgs ? import {} }:
pkgs.mkShell {
buildInputs = [
pkgs.python3
pkgs.poetry
];
}
Существует множество отчетов с множеством советов, например:
- https://www.pythonfixing.com/2023/11/fi ... ot-be.html
- Объясните, почему numpy не следует импортировать из исходного каталога
$ which python3
/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/bin/python3
snaqs-py3.12
(Я считаю, что snaqs-py3.12 — это имя моей виртуальной среды поэзии, но сбивает с толку, что оно добавляется к выводу любой команды... Хотелось бы избавиться от него, потому что оно ломается, т.е. зацикливается на выводе ls.
Я перепробовал все советы, но у меня ничего не работает. Буду признателен за любую помощь.
Спасибо.
/>Изменить: когда я запускаю скрипт, становится более ясно, что на самом деле Pandas пытается импортировать numpy, и это вызывает ошибку:
$ python pcs_interface.py -d
Traceback (most recent call last):
File "/home/freek/projects/snaqs3/src/snaqs/utils/pcs_interface.py", line 4, in
import pandas as pd
File "/home/freek/.cache/pypoetry/virtualenvs/snaqs-LIQmBdDd-py3.12/lib/python3.12/site-packages/pandas/__init__.py", line 19, in
raise ImportError(
ImportError: Unable to import required dependencies:
numpy: 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.
Подробнее здесь: https://stackoverflow.com/questions/795 ... y-from-its
Мобильная версия