Conda with Python3.9 using numpy in Python3.10

2guxujil  于 12个月前  发布在  Python
关注(0)|答案(1)|浏览(121)

我正在尝试在Conda环境中的Oracle Machine Learning中安装statsmodels。
我的conda版本是:

%conda
info

个字符
我用下面的命令创建了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版本?如何修复它?

mwngjboj

mwngjboj1#

此错误是由于自治数据库中OML 4Py包含的numpy库之间存在冲突。重新创建conda环境而不安装numpy将解决此问题:
%conda create -n arima_environment python=3.9 xz sqlite libuuid statsmodels

相关问题