sh0nk / matplotlib4j

Matplotlib for java: A simple graph plot library for java, scala and kotlin with powerful python matplotlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

does not work on windows running anaconda

omryoz opened this issue · comments

Tried to execute the sample code on jvm running on windows with anaconda 4.8.2 installed using default configuration (python3)- failed.
I've tried to configure py2 environment but executeSilently fails.

java.io.IOException: Cannot run program "bash": CreateProcess error=2, The system cannot find the file specified

The error says it's missing bash. It may have caused the error that it runs with bash when pyenvConfig is chosen.

Indeed I haven't tested on Windows, but it might run when WSL (Windows Subsystem for Linux) is enabled, so could you try that? Anyways added the comment about which OS was tested: ce978bc

This is really awesome!

As an update, I just tried on windows 10 pro 20H2 19042.985.

I made a test class

package Matplotlib;

import com.github.sh0nk.matplotlib4j.Plot;
import com.github.sh0nk.matplotlib4j.PythonExecutionException;
import java.io.IOException;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author tobid
 */
public class MatplotlibTest {

    public static void main(String[] args){
        Plot plt = Plot.create();
        plt.plot()
                .add(Arrays.asList(1.3, 2))
                .label("label")
                .linestyle("--");
        plt.xlabel("xlabel");
        plt.ylabel("ylabel");
        plt.text(0.5, 0.2, "text");
        plt.title("Title!");
        plt.legend();
        try {
            plt.show();
        } catch (IOException ex) {
            Logger.getLogger(MatplotlibTest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (PythonExecutionException ex) {
            Logger.getLogger(MatplotlibTest.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}

We are using ivy in our project. I installed the ivy dependency in our ivy.xml

            <dependency org="com.github.sh0nk" name="matplotlib4j" rev="0.5.0" />

matplotlib4j was downloaded fine. I just canceled the request for some mysterious authentication (something to do with ivy and github I don't understand).

On first run, the output told me to run python from cmd.exe to install python from windows store. I did this, the app store popped up and offered to install python 3.9. I did that, then ran "pip install matplotlib" in the cmd window, which went fine. Then I went back to netbeans and run the MatplotlibTest main method

The test plot popped right up.

2021-05-25_200848

This is really great, thank you for this excellent development!

@tobidelbruck Thank you for your installation details. Since I am not a Windows user, that information must be very helpful for other Windows users! Please feedback again if you meet anything weird.

How should we integrate anaconda environment to this library. The base python version of my Anaconda environment does not have matplotlib installed. How do I modify the pythonconfig object to use my Anaconda virtual enviornment?

@NeerajanS Since this library depends on matplotlib entirely, it does not work without matplotlib. Is it possible to install matplotlib on your anaconda environment? https://matplotlib.org/stable/users/installing/index.html#conda-packages