A guide to successfully install MT5 and MetaTrader5 package for Python on Linux.

 

I have successfully installed and used the MetaTrader5 package on Ubuntu without any difference on Windows. Here are the instructions.

1. Install Wine with the following command (skip if you already installed)

sudo apt install wine

2. Install the MetaTrader 5 platform for Linux according to the official instructions provided in MetaTrader 5 on Linux

3. Download Python 3.8 to your Downloads folder

cd ~/Downloads
wget https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe --no-check-certificate

4. Install Python 3.8 for the Windows environment in Wine. Assuming you are in the ~/Downloads folder

wine cmd
python-3.8.0-amd64.exe

5. After successfully installing Python 3.8, we install Jupyter Lab (or Notebook) for the Windows environment in Wine. Make sure you are still in the wine cmd environment

python -m pip install jupyterlab

6. Start Jupyter (again, ensure you are still in the wine cmd environment)

jupyter lab

7. The key point here is to install the MetaTrader5 package from Jupyter to avoid any path-related issues. After the Jupyter window opens, install MetaTrader5 using the following command

!python -m pip install MetaTrader5

8. You are done !


Note:

- Please ensure that you follow the instructions carefully and execute the commands in the appropriate environments.

- Just like on Windows, it is necessary to open an instance of MetaTrader 5 for the MetaTrader5 package to work.

 
Nio Pham:
sudo apt install wine

Thank you Nio, but step 5 cannot be executed without some additional work. Installing Python does not add it to the PATH. And adding the correct location to the PATH is no easy task in this case. It is not obvious where the installed running on wine cmd will store the Python executable.

 
Juan Guirao #:

Thank you Nio, but step 5 cannot be executed without some additional work. Installing Python does not add it to the PATH. And adding the correct location to the PATH is no easy task in this case. It is not obvious where the installed running on wine cmd will store the Python executable.

Hi Juan,

Thank you for your feedback. You are right, step 5 can only be executed if Python is already in the PATH of Wine environment. So, in step 4 while installing Python, make sure we enable the checkbox "Add Python 3.8 to PATH".

Otherwise, we can add Python to PATH variable manually as follows.

1. Find where was Python (and its modules) installed in Wine. I believe they locate at, for example

~/.wine/drive_c/users/niopham/Local Settings/Application Data/Programs/Python/Python38/
~/.wine/drive_c/users/niopham/Local Settings/Application Data/Programs/Python/Python38/Scripts/
~/.wine/drive_c/users/niopham/Local Settings/Application Data/Programs/Python/Python38/Lib/site-packages/

2. Then, in Linux terminal, run

wine regedit

3. Add the above paths to HKEY_CURRENT_USER/Environment/PATH. Assuming your Python locates as above, then you need to add the following line to the begining of the PATH variable

C:\users\niopham\Local Settings\Application Data\Programs\Python\Python38\;C:\users\niopham\Local Settings\Application Data\Programs\Python\Python38\Scripts\;C:\users\niopham\Local Settings\Application Data\Programs\Python\Python38\Lib\site-packages\;

4. Finally, you can verify again the updated PATH variable of Wine by running

wine cmd
echo %PATH%

Feel free to feedback.

 

Nice to read instructions on how to install MetaTrader5 on wine, but ... step 5 fails for me.

I get this error message

Preparing metadata (pyproject.toml) ... error
Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

So i have downloaded rustup-init.exe from the page rustup.rs, and tried to install it, but once again, i got an error

error: could not download file from 'https://static.rust-lang.org/dist/channel-rust-stable.toml.s
ha256' to 'C:\users\XXX\.rustup\tmp\74b751a_b4gwxqip_file': failed to make network request: error sending re
quest for url (https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256): error trying to connect: OS E
rror -2146762482 (FormatMessageW() returned error 317) (os error -2146762482): error trying to connect: OS Error
 -2146762482 (FormatMessageW() returned error 317) (os error -2146762482): OS Error -2146762482 (FormatMessageW(
) returned error 317) (os error -2146762482)

At this point, i have no idea on how to finish the installation of jupiterlab ...

Any idea ... ?

I need to say that when i use this command in wine

python -m pip install MetaTrader5

i got this error message

ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)
ERROR: No matching distribution found for MetaTrader5

So i have no idea on how to install this python library ...

 
thierry audic #:

Nice to read instructions on how to install MetaTrader5 on wine, but ... step 5 fails for me.....


Hi Thierry,

For your problem when installing Jupyter lab, I have no idea (did not happen to me).

However, I found a related post: https://discourse.jupyter.org/t/jupyter-lab-install-fails-without-rust/18065/2?u=fomightez

According to the author (Orome), the solution that worked for him is: "pip install -I y-py==0.5.5" (see also the answer of davidbrochart).


For your problem when installing MetaTrader5, I have some suggestions:

1. Make sure you are in CMD environment provided by Wine, not in the command line environment of Linux. This means you must run "wine cmd" first to enter into the CMD environment.

2. Probably that your python version is not compatible. Check "python --version" (again, make sure you are in CMD environment). If your version is supported by MetaTrader5 (as mentioned at https://pypi.org/project/MetaTrader5/) then I believe you should be able to install it properly.

Please feel free to update.

Reason: