Conda 与 Python3.9 在 Python3.10 中使用 numpy

问题描述 投票:0回答:1

我正在尝试在 Conda 环境中的 Oracle Machine Learning 中安装 statsmodels。

我的 conda 版本是:

%conda
info
active environment : None
            shell level : 0
       user config file : /u01/.condarc
 populated config files : /usr/share/conda/condarc.d/defaults.yaml
                          /u01/.condarc
          conda version : 4.6.14
    conda-build version : not installed
         python version : 3.6.8.final.0
       base environment : /usr  (read only)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /u01/.conda/pkgs
                          /var/cache/conda/pkgs
       envs directories : /u01/.conda/envs
                          /usr/envs
               platform : linux-64
             user-agent : conda/4.6.14 requests/2.27.1 CPython/3.6.8 Linux/5.4.17-2136.314.6.3.el7uek.x86_64 oracle/7.9 glibc/2.17
                UID:GID : 65000:65000
             netrc file : None
           offline mode : False

我使用下一个命令创建了 conda 环境:

%conda
create -n arima_enviroment python=3.9 xz sqlite libuuid statsmodels numpy

我用以下方法激活了环境:

%conda
activate arima_enviroment

测试环境:

%python
import sys
import platform

print("sys.version:", sys.version)
print("sys.version_info:", sys.version_info)
print("platform.python_version:", platform.python_version())
sys.version: 3.9.12 (main, Jun  1 2022, 11:38:51) [GCC 7.5.0]
sys.version_info: sys.version_info(major=3, minor=9, micro=12, releaselevel='final', serial=0)
platform.python_version: 3.9.12

然后我执行下一个命令来导入 ARIMA 模型。

%python
from statsmodels.tsa.arima_model import arima

但是给我下一个错误:

Fail to execute line 2: from statsmodels.tsa.arima_model import arima
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/usr/local/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/usr/local/lib/python3.10/site-packages/numpy/core/overrides.py", line 6, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/1675189382222-0/zeppelin_python.py", line 206, in <module>
    exec(code, _zcUserQueryNameSpace)
  File "<stdin>", line 2, in <module>
  File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tsa/__init__.py", line 1, in <module>
    from statsmodels.tools._testing import PytestTester
  File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tools/__init__.py", line 1, in <module>
    from .tools import add_constant, categorical
  File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tools/tools.py", line 4, in <module>
    import numpy as np
  File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 144, in <module>
    from . import core
  File "/usr/local/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.9 from "/u01/.conda/active_env/bin/python3"
  * The NumPy version is: "1.22.1"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'

为什么 conda 使用 Python 3.10 文件夹中的 Numpy,而不是 Python 3.9 中安装的 Numpy 版本?怎么修复?

numpy conda statsmodels arima oracle-cloud-infrastructure
1个回答
0
投票

此错误是自治数据库中 OML4Py 包含的 numpy 库之间冲突的结果。重新创建 conda 环境而不安装 numpy 将解决问题:

%康达 创建-n arima_enviroment python=3.9 xz sqlite libuuid statsmodels

© www.soinside.com 2019 - 2024. All rights reserved.