ImportError: numpy.core.multiarray failed to import

 

Hi

Can anyone help me with this import error? I did get numpy 1.19.1 installed and I still got this error. I am using conda enviroment. Please see below error message. Thank you so much for your help.


import numpy as np print(np.__version__)

1.19.2


--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5788/3086708213.py in <module>
----> 1 from MT5 import *   # we have error when importing so remove it need to fix it later(YLiu)
      2 import numpy as np
      3 import pandas as pd
      4 import warnings
      5 warnings.filterwarnings("ignore")

C:\Python_Sync\PythonforFinanceAlgorithmicTrading\Chapter_09\MT5.py in <module>
      2 from datetime import datetime
      3 import pandas as pd
----> 4 import MetaTrader5 as mt5
      5 warnings.filterwarnings("ignore")
      6 mt5.initialize()

~\AppData\Roaming\Python\Python38\site-packages\MetaTrader5\__init__.py in <module>
    255 
    256 # import C methods to our module
--> 257 from ._core import *
    258 
    259 # internal order send

ImportError: numpy.core.multiarray failed to import
 
anyone can help me? I tried to create a new environment and it never works, please help!  Thanks
 

pip install -U numpy

solved it for me
 
Blue Neurons #:

pip install -U numpy

solved it for me
Thank you Blue Neurons, Yes it works. I appreciate it.
 
Blue Neurons #:

pip install -U numpy

solved it for me
Same problem, solved !! Tks
 
I'm getting the same error and untalling /reinstalling numpy or updating it doesn't help
 
use old v of metatrader5
 

Im having similar issues now .

this is the error message i get was a NumPy version incompatibility. The MetaTrader5 library was likely compiled with an older version of NumPy, and your current NumPy version (2.1.0) was causing a conflict. 

ive tried it all with the command prompts trying to downgrade numpy but it doesnt work

HELP PLEASE

 
roudan:

Hi

Can anyone help me with this import error? I did get numpy 1.19.1 installed and I still got this error. I am using conda enviroment. Please see below error message. Thank you so much for your help.


import numpy as np print(np.__version__)


--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

HOW DID YOU GET NUMPY 1.19.1 INSTALLED??
 

Hi Yaw Turkson , did you find a solution? I'm having the same problem at the moment. I've been trying to solve it for quite some time and nothing seems to work.



Yaw Turkson #:

Im having similar issues now .

this is the error message i get was a NumPy version incompatibility. The MetaTrader5 library was likely compiled with an older version of NumPy, and your current NumPy version (2.1.0) was causing a conflict. 

ive tried it all with the command prompts trying to downgrade numpy but it doesnt work

HELP PLEASE

 

The issue for me as I would imagine would be for many was that Metatrader5 api has a requirement of any version of numpy declared in it's dependency list. This is wrong. It was correct until numpy 2.0 was released as numpy 2.0 wont work with the metatrader5 as i presume 2 has breaking changes.

The solution is to make sure your installed version of numpy is 1.26 or lower and that metatrader5 is using that version. I used pipenv to control my  dependencies and the following line solved the issue for me after I'd installed the latest metatrader5 api

pipenv install numpy==1.26

Good luck