MetaTrader 5 Python User Group - how to use Python in Metatrader - page 19

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
1. I originally had Python 3.7.2 installed. Installed your package and the command shell and Jupyter notepad pops up the same error: RuntimeError: IPC call failed
2. I ripped Python 3.7.2, installed Python 3.8, but the same story - it doesn't install in Python 3.8
3. Installed Anaconda Python, specifically created a virtual environment for Python 3.7.2 and tried to pip your package and run the example - same view, but on the side: RuntimeError: IPC call failed
doing something wrong
A good tutorial on how to work with data and a bit of MO if there's something you didn't know, but have forgotten. Including a tip on how to stop thinking that python is retarded.
https://jakevdp.github.io/PythonDataScienceHandbook/
Here's the report in Python 3.8
C:\Users\labor>pip install MetaTrader5
Collecting MetaTrader5
Using cached https://files.pythonhosted.org/packages/3c/c8/713f1b8283cbbdef30dc9cf50a5d767f9b4a194eb4f886a8e50074b696a1/MetaTrader5-5.0.6.tar.gz
Installing collected packages: MetaTrader5
Running setup.py install for MetaTrader5 ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python38\python.exe' -u -c'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\\labor\\AppData\Local\\\Temp\\pip-install-283aremb\\MetaTrader5\\setup.py'"'"'; __file__='"'"'C:\\Users\\labor\\AppData\\Local\\Temp\\pip-install-283aremb\\MetaTrader5\\setup.py''';f=getattr(tokenize, ''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec''')'' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-t10_91ai\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\labor\AppData\Local\Temp\pip-install-283aremb\MetaTrader5\
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\MetaTrader5
copying MetaTrader5\__init__.py -> build\lib.win-amd64-3.8\MetaTrader5
running build_ext
building 'MetaTrader5.C' extension
creating build/temp.win-amd64-3.8
creating build/temp.win-amd64-3.8/Release
creating build\temp.win-amd64-3.8\release\src
creating build\temp.win-amd64-3.8\Release\src\Interprocess
creating build\temp.win-amd64-3.8\Release\src\Connector
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DUNICODE -Isrc -Ic:\python38\include -Ic:\python38\include /EHsc /Tpsrc/MetaTrader.cpp /Fobuild\temp.win-amd64-3.8\Release\src/MetaTrader.obj
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\labor\AppData\\Local\\Temp\pip-install-283aremb\\MetaTrader5\\setup.py'''; __file__=''''C:\Users\\labor\\AppData\Local\\Temp\pip-install-283aremb\MetaTrader5\\setup.py''';f=getattr(tokenize, ''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec'''))' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-t10_91ai\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
Here is the report in Python 3.7.2
Created a project in JreBrains IDE under Python 3.7.2. Loaded the test file metatrader5-test.py and got the same result:
C:\Users\labor\Anaconda3\envs\metatrader5\python.exe C:/Users/labor/Downloads/MetaTrader5-Python/metatrader5-test.py
Traceback (most recent call last):
File "C:/Users/labor/Downloads/MetaTrader5-Python/metatrader5-test.py", line 10, in <module>
ticks1 = MT5CopyTicksFrom('EURAUD', datetime(2019,1,28,13), 10000, MT5_COPY_TICKS_ALL)
[2, 'Exness-MT5Real', '0000000'] # zeros close the real code
RuntimeError: IPC call failed
[500, 2174, '11 Oct 2019']
Process finished with exit code 1
Note: localhost in Options -> Expert Advisers added. Does not work.
Stumbles on :
ticks1= MT5CopyTicksFrom("EURAUD", datetime(2019,1,28,13),10000, MT5_COPY_TICKS_ALL)
...
RuntimeError: IPC call failed
Path to the terminal is through r (raw). The terminal itself is detected, of course.
Here is the report in Python 3.8
C:\Users\labor>pip install MetaTrader5
Collecting MetaTrader5
Using cached https://files.pythonhosted.org/packages/3c/c8/713f1b8283cbbdef30dc9cf50a5d767f9b4a194eb4f886a8e50074b696a1/MetaTrader5-5.0.6.tar.gz
Installing collected packages: MetaTrader5
Running setup.py install for MetaTrader5 ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python38\python.exe' -u -c'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\\labor\\AppData\Local\\\Temp\\pip-install-283aremb\\MetaTrader5\\setup.py'''; __file__=''''C:\Users\\labor\AppData\Local\\Temp\pip-install-283aremb\\\MetaTrader5\\setup.py''';f=getattr(tokenize, ''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec''')'' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-t10_91ai\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\labor\AppData\Local\Temp\pip-install-283aremb\MetaTrader5\
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\MetaTrader5
copying MetaTrader5\__init__.py -> build\lib.win-amd64-3.8\MetaTrader5
running build_ext
building 'MetaTrader5.C' extension
creating build/temp.win-amd64-3.8
creating build/temp.win-amd64-3.8/Release
creating build\temp.win-amd64-3.8\release\src
creating build\temp.win-amd64-3.8\Release\src\Interprocess
creating build\temp.win-amd64-3.8\Release\src\Connector
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DUNICODE -Isrc -Ic:\python38\include -Ic:\python38\include /EHsc /Tpsrc/MetaTrader.cpp /Fobuild\temp.win-amd64-3.8\Release\src/MetaTrader.obj
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\labor\AppData\\Local\\Temp\pip-install-283aremb\\MetaTrader5\\setup.py'''; __file__=''''C:\Users\\labor\\AppData\Local\\Temp\pip-install-283aremb\MetaTrader5\\setup.py''';f=getattr(tokenize, ''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec'''))' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-t10_91ai\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
Here is the report in Python 3.7.2
Created a project in JreBrains IDE under Python 3.7.2. Loaded the test file metatrader5-test.py and got the same result:
C:\Users\labor\Anaconda3\envs\metatrader5\python.exe C:/Users/labor/Downloads/MetaTrader5-Python/metatrader5-test.py
Traceback (most recent call last):
File "C:/Users/labor/Downloads/MetaTrader5-Python/metatrader5-test.py", line 10, in <module>
ticks1 = MT5CopyTicksFrom('EURAUD', datetime(2019,1,28,13), 10000, MT5_COPY_TICKS_ALL)
[2, 'Exness-MT5Real', '0000000'] # zeros close the real code
RuntimeError: IPC call failed
[500, 2174, '11 Oct 2019']
Process finished with exit code 1
Note: localhost in Options -> Expert Advisers added. Does not work.
In first case I think I need some compiler to build the package. Mb the developers will answer. I have everything working on 3.7
When this happens is the terminal working, i.e. it is not frozen (e.g. the menu is working)?
In the first case you need some kind of compiler, I understand, to build the package. Mb the developers will answer. I have everything working on 3.7
And how to compile it, if there is no Git of this package, no sources?
It compiles itself when the package is installed on your computer, for this you need to install some cis compiler, e.g. cL.exe as it says in the logs. The process can't find it with you
Downloaded VC_redist.x64.exe. No luck so far and I'm sure I shouldn't be doing this - it's up to the developer, isn't it? At the very least there should be detailed documentation that takes all cases into account. Universum is not that big - only 3 branches of operating systems - Win/Linux/MacOS:
C:\Users\labor>pip install MetaTrader5
Collecting MetaTrader5
Using cached https://files.pythonhosted.org/packages/3c/c8/713f1b8283cbbdef30dc9cf50a5d767f9b4a194eb4f886a8e50074b696a1/MetaTrader5-5.0.6.tar.gz
Installing collected packages: MetaTrader5
Running setup.py install for MetaTrader5 ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python38\python.exe' -u -c'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\\labor\\AppData\Local\\\\Temp\\pip-install-d68bdu0o\\MetaTrader5\\setup.py'"'"'; __file__='"'"'C:\\Users\\labor\\AppData\\Local\\Temp\\pip-install-d68bdu0o\\MetaTrader5\\setup.py''';f=getattr(tokenize, '''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec''')'' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-mt16672p\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\labor\AppData\Local\Temp\pip-install-d68bdu0o\MetaTrader5\
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\MetaTrader5
copying MetaTrader5\__init__.py -> build\lib.win-amd64-3.8\MetaTrader5
running build_ext
building 'MetaTrader5.C' extension
creating build/temp.win-amd64-3.8
creating build/temp.win-amd64-3.8/Release
creating build\temp.win-amd64-3.8\release\src
creating build\temp.win-amd64-3.8\Release\src\Interprocess
creating build\temp.win-amd64-3.8\Release\src\Connector
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DUNICODE -Isrc -Ic:\python38\include -Ic:\python38\include /EHsc /Tpsrc/MetaTrader.cpp /Fobuild\temp.win-amd64-3.8\Release\src/MetaTrader.obj
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\labor\\AppData\\Local\\Temp\pip-install-d68bdu0o\\\MetaTrader5\\setup.py'''; __file__=''''C:\Users\\labor\\AppData\Local\\Temp\pip-install-d68bdu0o\MetaTrader5\\setup.py''';f=getattr(tokenize, '''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec''')'' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-mt16672p\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
Downloaded VC_redist.x64.exe. No luck so far and I'm sure I shouldn't be doing this - it's up to the developer, isn't it?
C:\Users\labor>pip install MetaTrader5
Collecting MetaTrader5
Using cached https://files.pythonhosted.org/packages/3c/c8/713f1b8283cbbdef30dc9cf50a5d767f9b4a194eb4f886a8e50074b696a1/MetaTrader5-5.0.6.tar.gz
Installing collected packages: MetaTrader5
Running setup.py install for MetaTrader5 ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python38\python.exe' -u -c'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\\labor\\AppData\Local\\\\Temp\\pip-install-d68bdu0o\\MetaTrader5\\setup.py"''; __file__="""C:\Users\\labor\AppData\Local\\Temp\pip-install-d68bdu0o\\MetaTrader5\\\setup.py''';f=getattr(tokenize, '''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec''')'' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-mt16672p\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\labor\AppData\Local\Temp\pip-install-d68bdu0o\MetaTrader5\
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\MetaTrader5
copying MetaTrader5\__init__.py -> build\lib.win-amd64-3.8\MetaTrader5
running build_ext
building 'MetaTrader5.C' extension
creating build/temp.win-amd64-3.8
creating build/temp.win-amd64-3.8/Release
creating build\temp.win-amd64-3.8\release\src
creating build\temp.win-amd64-3.8\Release\src\Interprocess
creating build\temp.win-amd64-3.8\Release\src\Connector
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DUNICODE -Isrc -Ic:\python38\include -Ic:\python38\include /EHsc /Tpsrc/MetaTrader.cpp /Fobuild\temp.win-amd64-3.8\Release\src/MetaTrader.obj
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'''C:\Users\\\labor\AppData\\Local\\Temp\pip-install-d68bdu0o\\\MetaTrader5\\setup.py'''; __file__=''''C:\Users\labor\\\AppData\Local\\Temp\pip-install-d68bdu0o\MetaTrader5\\setup.py''';f=getattr(tokenize, '''''open''', open)(__file__);code=f.read().replace(''''\r\n''', '''''\n''');f.close();exec(compile(code, __file__, '''exec'''))' install --record 'C:\Users\labor\AppData\Local\Temp\pip-record-mt16672p\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
I think that's what Microsoft build tools were missing, that's what they write:
https://stackoverflow.com/questions/41724445/python-pip-on-windows-command-cl-exe-failed
i.e. add cl.exe to the PATH, or open a command line from the folder where it is installed and pip install metatrader5 from there
the developers don't have to, the system just doesn't see the compiler
Microsoft build tools seemed to be exactly what was missing, this is what they say:
https://stackoverflow.com/questions/41724445/python-pip-on-windows-command-cl-exe-failed
i.e. add cl.exe to the PATH, or open a command line from the folder where it is installed, and pip install metatrader5 from there
The developers don't have to, the system just doesn't see the compiler.
At least there should be detailed documentation that takes all cases into account. Universum is not that big - only 3 branches of operating systems - Win/Linux/MacOS.
Installed Microsoft build tools from https://visualstudio.microsoft.com/ru/downloads/?rr=https%3A%2F%2Fwww.google.com%2F. The package is now installed in Python 3.8. This problem is SOLVED.
C:\Users\labor>pip install MetaTrader5
Collecting MetaTrader5
Using cached https://files.pythonhosted.org/packages/3c/c8/713f1b8283cbbdef30dc9cf50a5d767f9b4a194eb4f886a8e50074b696a1/MetaTrader5-5.0.6.tar.gz
Installing collected packages: MetaTrader5
Running setup.py install for MetaTrader5 ... done
Successfully installed MetaTrader5-5.0.6
BUT! RuntimeError: IPC call failed:
C:\Users\labor>C:\Users\labor\Anaconda3\envs\metatrader5\python.exe C:/Users/labor/Downloads/MetaTrader5-Python/metatrader5-test.py
[2, 'Exness-MT5Real', '0000000'] # code is zeroed in the printout
[500, 2174, '11 Oct 2019']
Traceback (most recent call last):
File "C:/Users/labor/Downloads/MetaTrader5-Python/metatrader5-test.py", line 10, in <module>
ticks1 = MT5CopyTicksFrom("EURAUD", datetime(2019,1,28,13), 10000, MT5_COPY_TICKS_ALL)
RuntimeError: IPC call failed