Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用PyO3从锈迹中加载Numpy时,类型扩展出现问题_Python_Numpy_Rust_Anaconda_Pyo3 - Fatal编程技术网

Python 用PyO3从锈迹中加载Numpy时,类型扩展出现问题

Python 用PyO3从锈迹中加载Numpy时,类型扩展出现问题,python,numpy,rust,anaconda,pyo3,Python,Numpy,Rust,Anaconda,Pyo3,我试图使用pyO3,在康达环境中使用numpy,防止生锈。 为了让pyO3链接,我还使用conda安装了GCC工具链 我现在可以做一些简单的事情,比如显示sys.path。但是,当我尝试导入numpy时,如下所示: use pyo3::prelude::*; use pyo3::types::IntoPyDict; fn main() -> PyResult<()> { let gil = Python::acquire_gil(); let py = gil

我试图使用pyO3,在康达环境中使用numpy,防止生锈。 为了让pyO3链接,我还使用conda安装了GCC工具链

我现在可以做一些简单的事情,比如显示
sys.path
。但是,当我尝试导入numpy时,如下所示:

use pyo3::prelude::*;
use pyo3::types::IntoPyDict;

fn main() -> PyResult<()> {
    let gil = Python::acquire_gil();
    let py = gil.python();

    let r = py.import("numpy");
    match r {
        Ok(_) => println!("OK"),
        Err(e) => e.print(py),
    }

    Ok(())
}
使用pyo3::prelude::*;
使用pyo3::types::IntoPyDict;
fn main()->PyResult{
让gil=Python::acquire_gil();
设py=gil.python();
设r=py.import(“numpy”);
火柴{
Ok()=>println!(“Ok”),
误差(e)=>e.print(py),
}
好(())
}
发生以下情况:

Traceback (most recent call last):
  File "<HOME>/anaconda3/envs/pyrust/lib/python3.7/site-packages/numpy/__init__.py", line 140, in <module>
    from . import _distributor_init
  File "<HOME>/anaconda3/envs/pyrust/lib/python3.7/site-packages/numpy/_distributor_init.py", line 33, in <module>
    with RTLD_for_MKL():
  File "<HOME>/anaconda3/envs/pyrust/lib/python3.7/site-packages/numpy/_distributor_init.py", line 18, in __enter__
    import ctypes
  File "<HOME>/anaconda3/envs/pyrust/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: <HOME>/anaconda3/envs/pyrust/lib/python3.7/lib-dynload/_ctypes.cpython-37m-x86_64-linux-gnu.so: undefined symbol: PyUnicode_FromFormat
回溯(最近一次呼叫最后一次):
文件“/anaconda3/envs/pyrust/lib/python3.7/site packages/numpy/_init__.py”,第140行,在
从…起导入\u分发服务器\u初始化
文件“/anaconda3/envs/pyrust/lib/python3.7/site packages/numpy/_distributor_init.py”,第33行,在
使用RTLD_for_MKL():
文件“/anaconda3/envs/pyrust/lib/python3.7/site packages/numpy/\u distributor\u init.py”,第18行,输入__
导入ctypes
文件“/anaconda3/envs/pyrust/lib/python3.7/ctypes/_init__.py”,第7行,在
从类型导入联合、结构、数组
导入错误:/anaconda3/envs/pyrust/lib/python3.7/lib-dynload//\u ctypes.cpython-37m-x86\u 64-linux-gnu.so:未定义的符号:PyUnicode\u FromFormat
有趣的是,当我只键入python-c“import numpy”时,问题并没有出现


我使用
RUSTFLAGS=“-C linker=$CC”cargo+nightly run
来构建和运行代码,如果这样有帮助的话。

这方面运气好吗?运气好吗?