Python Import Metatrader 5 crashes

 

On Anaconda3 shell I have installed Metatrader 5 package using pipenv. My Python script does an import Metatrader 5; and immediately the program crashes (as seen from pdb step line by line). Windows Event log has the below, apparently pointing to some math libaries:

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Application Error" />
  <EventID Qualifiers="0">1000</EventID>
  <Version>0</Version>
  <Level>2</Level>
  <Task>100</Task>
  <Opcode>0</Opcode>
  <Keywords>0x80000000000000</Keywords>
  <TimeCreated SystemTime="2023-01-07T08:41:12.7808684Z" />
  <EventRecordID>2741</EventRecordID>
  <Correlation />
  <Execution ProcessID="0" ThreadID="0" />
  <Channel>Application</Channel>
  <Computer>DESKTOP-FTG6RSN</Computer>
  <Security />
  </System>
- <EventData>
  <Data>python.exe</Data>
  <Data>3.9.12150.1013</Data>
  <Data>624ac9fe</Data>
  <Data>_multiarray_umath.cp39-win32.pyd</Data>
  <Data>0.0.0.0</Data>
  <Data>63a91ba6</Data>
  <Data>c000001d</Data>
  <Data>000269c9</Data>
  <Data>2660</Data>
  <Data>01d92273cb431db6</Data>
  <Data>C:\Users\acer\anaconda3\python.exe</Data>
  <Data>C:\Users\acer\anaconda3\lib\site-packages\numpy\core\_multiarray_umath.cp39-win32.pyd</Data>
  <Data>7729512c-4535-4138-a1e7-770ed4ec6ef8</Data>
  <Data />
  <Data />
  </EventData>
  </Event>

I have Metatrader5 package 5.0.37, Python 3.9.12 and Windows 10 32 bit. Any help on how to resolve this is much appreciated and please do so before I shoot myself.

 

Just considering the error message you shared, I have a feeling that your problem might not be related to Metatrader5 but instead with your conda installation or numpy package.

I assume you installed Anaconda (not miniconda) and your environment has multiple Python packages already installed.


If you haven't already, I suggest you create your own conda environment (documentation here) and in your yml file use only following packages:


python any version > 3.10 and < 3.11 

numpy 1.20+

MetaTrader5 5.0.43 (source should be pip / pypi)


If conda is not a must, I suggest Poetry for environment management.

Managing environments — conda 22.11.1.post24+48f51e6c1 documentation
  • conda.io
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment. You can also share an environment file. Creating an environment with commands Use the terminal or an Anaconda Prompt...