I have seen the following posts (- – -) but they are all related to classes that people have written themselves. I call a function from a ready library that works fine on Windows but fails on Linux.
I use MetaTrader5
in Ubuntu server 22.04 GUI to run a Python script as a trader bot.
My script worked on Windows definitely, however, when I ran the script on the Linux server I got this error:
TypeError: MetaTrader5.initialize() missing 1 required positional argument: 'self'
It’s the part of my script that caused this error:
from mt5linux import MetaTrader5 as mt5
mt5.initialize(login=111111, password='fjfklsfja', server = 'test-server')
this error has occurred even if I use the simple function on MetaTrader
such as:
mt5.version()
Why does it get this error even though I have provided all the required parameters of the function? Even the simple function version
, which has no input parameters, faces this problem.
Edit:
It’s an example of MetaTrader
initialization in its documentation.
import MetaTrader5 as mt5
# display data on the MetaTrader 5 package
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# establish MetaTrader 5 connection to a specified trading account
if not mt5.initialize(login=25115284, server="MetaQuotes-Demo",password="4zatlbqx"):
print("initialize() failed, error code =",mt5.last_error())
quit()
It works on Windows but fails in Linux.
4